noob question: UI component.set()
-
hey there,
i have created a couple of buttons with a custom image using LAF and added these to an array.
i edited the JSON objects in the component list to have an extra property called "group", which i intend to change on a control callback and then use inside the LAF of each button to change the Y offset of the image (to display a different state).
Inside my control callback, I can Console.print the value of "group" via component.get("group") and it will display correctly.
but when I try to use component.set("group", 2(or whatever)), i get an error that the property was not found.
can somebody help me out?
cheers! -
@prehm said in noob question: UI component.set():
i edited the JSON objects in the component list to have an extra property called "group",
This won't work unfortunately, you can't add new properties to components, only edit existing ones. The fact that
get
is returning the value you've added to the JSON is a quirk.Why are you using LAF to apply an image to a button? Buttons already have an image property that handles the offset for different button states.
-
ah I see, thats unfortunate.
my buttons have four different states, and should go to the next one on each click.
as far as i understood the stock buttons only support states for on/off/hover states, that why i went for look and feel, and because i might want to experiment with blend modes later on, which (i think) are not available outside look and feel (?)i now used the text property and parseInt to set my value, which doesnt feel clean but works.
is there maybe a list somewhere of the properties that can be used in a UI json object? i looked in hise.docs but didn't find anything.cheers!
-
@prehm For a multi-state button a better choice is probably to use a panel, and you can set its value from 0-3. with each click and use mod (%) to loop back round to zero.
-
@prehm This will be useful for you:
-
@HISEnberg
oh very cool thanks!
so if i understand correctly, using obj.data allows me to define control data that couldn't be set using the UI json object? or is the data object also limited to specific properties? -
@prehm there's been a few posts floating around on the topic of panels lately. Hypothetically the panel can store both UI and control data. In practice, for control data, it is best to use another component and reflect UI changes in the panel. So in your case, maybe try using a hidden knob for your four-button state, and using mousecallbacks and a paint routine on the panel to interact with and change the state of the knob.
You could bypass the knob altogether, I sometimes find issues with it when trying load presets or initialize the project. Really depends on what you are trying to do though.
saveInPreset not working for panel data?
@VirtualVirgin You could do it like this which might make it seem like it makes more sense const panelObj = Panel1.getValue(); Console.print(panelObj.test1);
Forum (forum.hise.audio)
Is panel.data persistent?
I thought it was, but this snippet seems to show otherwise. HiseSnippet 984.3ocsVstaaaCElxwpq1asXEnO.B5WJaFAVdtNdscXcwIY0aKIF0YA6eELTGGSDIRAR5rYTzm08Jr2fsC0k...
Forum (forum.hise.audio)