teotigraphix / Framework4Bitwig

Bitwig controller API framework extensions.
GNU Lesser General Public License v3.0
59 stars 13 forks source link

EnumSetting does not fire on script start #185

Closed git-moss closed 7 years ago

git-moss commented 7 years ago

E.g. check with "Display crossfader" setting of P4B script.

NickJAllen commented 7 years ago

enumSetting = host.getPreferences().getEnumSetting("test", "category", ["one", "two", "three"], "one"); enumSetting.addValueObserver(function(value) { println ("category/test = " + value); });

I added this to a debug script and it fires one initially as expected. If I change the setting in prefs and then restart the script it also fires the new value. So I can't seem to reproduce this...

NickJAllen commented 7 years ago

I've stepped through the code and we seem to notify the observer correctly. I wonder if there is a bug in your code somewhere? Perhaps using string1 == string2 instead of string1.equals(string2)? Haven't ruled out that this is a bug on our side but so far it does not appear to be...

NickJAllen commented 7 years ago

So this turns out that you are calling some things before the init method is called. The Host.getPreferences() should only be called during init(). I'm updating so you get a notification that you did something wrong in this case...