setValue is not updating widget state

Home Forums Control setValue is not updating widget state

This topic contains 1 reply, has 1 voice, and was last updated by  Neurogami 5 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #93279

    Neurogami
    Member

    This is a weird problem because I have one interface where this works fine, but in my new interface I’m having trouble with setValue().

    I have two toggle buttons (‘alt’ and ‘ctrl’), and some other contact buttons (‘o’, ‘s’).

    When pressing one of the latter buttons the script should reset those toggle buttons back to 0.

     

    Those latter buttons invoke this function:

     
    resetModKeys : function() {
    altMod.setValue(1);
    ctrlMod.setValue(1);
    alert(“reset mods”);
    },
     

    On the toggle buttons I have this (for testing)
     “onvaluechange”: “oscManager.sendOSC( [ ‘/ng/test’,  ‘i’, this.value ]); “,
    I see the alert, I see the proper toggle button value (0, which is what I want) sent over OSC, but the toggle buttons do not change color and if I press them again I find they still have the previous value of 1; if I press them they send OSC indicating  they’ve now changed to 0.

    Is there some trick or or quirk  or edge case I need to look for in using setValue()?  For the life of me I cannot see why this shouldn’t work as it does in my other interface; it’s as if the widget has two different places it tracks the ‘value’ property.

     

     

    • This topic was modified 5 years ago by  Neurogami.
    #93281

    Neurogami
    Member

    AH HA!  Clearly the best way to solve a problem is to write it out and hit ‘send’.   I was thinking about ” it’s as if the widget has two different places it tracks the ‘value’ property.”   Turns out, that’s exactly the case.

    I’ve been refactoring my designs so that I can call common functions to generate buttons and arrays of buttons, usually for things I want appearing in multiple place.

    My code for generating these mod buttons did not account for unique names; I ended up with two widgets  named ctrlMod , and two named altMod.  The result was that  I was setting the value for one while interacting with another.

    I now added a function param for the page number as well as the modifier type so each widget has a unique name;  Presto! All is good.

    Lesson learned: If something is not responding as expected see if you are inadvertently reusing widget names.

     

    • This reply was modified 5 years ago by  Neurogami.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

This work is licensed under GPL - 2009 | Powered by Wordpress using a heavily modified version of the theme aav1