Default button state on load
-
I have a toggle button that controls the visibility of a panel.
Panel defaults to visible on load, and the button default value set to
1.0in interface designer props.But when I load the project the button is in the 'off' state, which doesn't match the panel display state.
Do I have to script the 'on' value in
onInit, or is there a way to do it just in the interface designer?Content.getComponent("btnShowPanel").setValue(1.0); -
@dannytaurus
That's how I always do it. -
@Oli-Ullmann Cools, cheers

-
@dannytaurus said in Default button state on load:
Do I have to script the 'on' value in onInit,
Is the button set to saveInPreset?
-
@David-Healey No, it's for a show/hide tooltips panel.
I suppose I should be saving the value somewhere so it survives across plugin loads.
Are there any docs/examples for saving user preferences?EDIT: found an example: https://docs.hise.dev/tutorials/scripting/index.html#user-preference-system
-
@dannytaurus You could also invert your logic so
!valueactually means the panel is showing -
@ustk
That's a cool idea! -
@ustk Could do, but I prefer to keep the button's 'on' state synced to the panel's visible state.
If I start flipping values as a workaround, my future self will not thank me when he looks at the code in 2 years!

-
Another option is to have the panel and the button watch each other's states using broadcasters.
-

-
-
@David-Healey
far worse than all I imagined 
