Control

forum for discussing Control interface software

Register or log in - lost password?

Control » General

Changing Button Label

(8 posts) (2 voices)
  • Started 1 year ago by paul@villagerstheatre.com
  • Latest reply from admin

Tags:

  • baby halloween costume
  • bounds
  • cartier love bracelet
  • cartier love rings
  • cheap prom dress
  • christian louboutin yellow pumps shoes
  • christian louboutins boots
  • designer clothes
  • dmx
  • fake watches for men
  • French Maid Costumes
  • lanbox
  • lighting
  • lovebraceletsell
  • mermaid bridesmaid dresses
  • short prom dresses 2011
  • used Rolex watches
  • white flower girl dresses
  1. paul@villagerstheatre.com
    Member

    Sorry if I've missed it but I can't seem to find in the documentation the syntax to change a button label. I'm doing the following:

    {
    "name": "bbms",
    "type": "Button",
    "value": 0,
    "label": "BlackBox",
    "x": .38,
    "y": .65,
    "width": .375,
    "height": .075,
    "mode": "momentary",
    "color": "#00a0a0",
    "stroke": "#00c0c0",
    "isLocal":true,
    "ontouchstart": "if(this.value == 0)
    {this.setValue(1);this.setLabel('Mainstage');}
    else{this.setValue(0);this.setLabel('BlackBox')};",
    },

    Without the "ontouchstart" line I get a button that flashes when I touch it. With the "ontouchstart" line the button doesn't respond to touch at all.

    What I'm trying to achieve here is a button that toggles between two different text labels when you press it.

    Once I've got that working I'm hoping to add the following code to it:

    "rfu.address='/rfubb';rfu.columns=5;rfu.rows=5" for one case and
    "rfu.address='/rfums';rfu.columns=7;rfu.rows=7" for the other case.

    "rfu" is a MultiButton.

    This is for a remote focus unit for lights. We have 24 dimmers in our Black Box and 45 dimmers in our Mainstage. I'd like to toggle between a 25 MultiButton and a 49 Multibutton depending on which theatre I'm in.

    All the dimmers are on the same DMX controller and I have a Perl script on the lighting control computer translating OSC. I plan to have the Perl script use the OSC address /rfubb or /rfums to translate the MultiButton numbers to the correct DMX offset.

    Posted 1 year ago #
  2. admin
    Key Master

    Hi Paul,

    I don't have this documented anywhere, but buttons (that have labels) store their labels in the label instance variable. Basically there's a separate label widget that's associated with the button and gets created automatically.

    So, you should be able to do something like this:

    "ontouchstart" : "this.label.setValue('test')"

    Hope this helps... - Charlie

    Posted 1 year ago #
  3. paul@villagerstheatre.com
    Member

    Ok, that got me closer. The button label now toggles but the MultiButton doesn't change. Is it valid to resize a MultiButton in this way or do I need to use two MultiButtons on different pages and switch between pages rather than changing the MultiButton?

    This is what I've got (ignoring other hopefully unrelated widgets):

    {
    "name": "rfu",
    "type": "MultiButton",
    "shouldLabel": true,
    "x": 0,
    "y": 0,
    "rows": 5,
    "columns": 5,
    "width": .8,
    "height": .6,
    "startingValue": 0,
    "color": "#000090",
    "stroke": "#0000e0",
    "min": 0,
    "max": 255,
    "mode": "toggle",
    "address": "/rfu",
    "requiresTouchDown": false,
    "isLocal": true,
    "onvaluechange": "if(this.value == 255)
    {oscManager.sendOSC(this.address,'f',Math.round(levelSlider.value))}
    else{oscManager.sendOSC(this.address,'f',0);};",
    },
    {
    "name": "bbms",
    "type": "Button",
    "value": 0,
    "label": "BlackBox",
    "x": .38,
    "y": .65,
    "width": .375,
    "height": .075,
    "mode": "momentary",
    "color": "#00a0a0",
    "stroke": "#00c0c0",
    "isLocal":true,
    "ontouchstart": "if(this.label.value == 'BlackBox'){this.label.setValue('Mainstage');rfu.columns.setValue(7);rfu.rows.setValue(7);}
    else{this.label.setValue('BlackBox');rfu.columns.setValue(5);rfu.rows.setValue(5);};",
    },

    Posted 1 year ago #
  4. admin
    Key Master

    A MultiButton (and MultiSliders as well) is just a collection of Button widgets that's grouped together for convenience. There's no way to dynamically change the number of buttons.

    What you can do is remove the existing widget and put another multibutton in its place. If you have the JSON for a multibutton widget stored in a variable named widgetJSON you could call the following:

    control.removeWidgetWithName("yourMultiButtonName");
    var _w = control.makeWidget(widgetJSON);
    control.widgets.push(_w);
    control.addWidget(w.name, control.currentPage);

    I need to make a one line method to add a new widget with a piece of JSON, but for now you can use those three lines together and it should work. Hope this helps.

    Changing the page is also a good solution and actually makes more sense to me, but you have a pretty complicated setup so use whatever works best for your situation. - Charlie

    Posted 1 year ago #
  5. paul@villagerstheatre.com
    Member

    Well, that sort of worked but not quite. It looks like the new widget was added but the old one wasn't deleted.

    I switched tactics and made two separate pages. This seems like a bit of a brute force solution to me since I want all the same buttons on both pages and only the multibutton to change, but it does the job. I copied and pasted the JSON for my entire page into another page and appended _bb to all the widgets on one page and _ms to all the widgets on the other page so that I wouldn't have naming conflicts.

    Posted 1 year ago #
  6. admin
    Key Master

    Sorry, did you know about the constants variable? You place widgets in there that you want to span multiple pages... check out the multipage template for an example:

    http://charlie-roberts.com/Control/interfaces/multipage_template.js

    This should help a little bit - Charlie

    Posted 1 year ago #
  7. paul@villagerstheatre.com
    Member

    That's helpful, thanks. I must have missed that it of information.

    Posted 1 year ago #
  8. admin
    Key Master

    Or, more likely, it's undocumented... I'll try and make sure it gets added in there.

    Posted 1 year ago #

RSS feed for this topic

Control is proudly powered by bbPress.