You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `this` keyword is only meaningful inside the three callbacks, but it allows a totally encapsulated widget.
367
367
368
-
### Control Data
369
-
370
-
The control data is the data that actually represents the current value of the widget:
371
-
372
-
-`1` / `0` for toggle buttons
373
-
-`double` numbers for slider types
374
-
-`int` numbers for discrete widgets like combobox selectors.
375
-
376
-
You access and store **Control Value** just like with any other UI type in HISE: using the `setValue(value)` / `getValue()` methods. This feature is deactivated by default, so if you create a UI widget that uses a **Control Value**, you have to set the `saveInPreset` property of the Panel to `true`
368
+
Values stored in `data` are always non-persistent even if the panel has `saveInPreset` set to true.
377
369
378
-
It's heavily recommended that this will be just a simple number, but you can choose to use more complex types if your widget that demands that (we'll cover this case in a example later on). But even then it might be more efficient to store the actual value as an array in the `data` object and use the **Control Value** as index:
370
+
It's heavily recommended to store a simple number whenever possible, but you can choose to use more complex types if your widget demands it (we'll cover this case in a example later on). Even then it might be more efficient to store the possible values as an array in the `data` object, and use the **Control Value** as an index:
In other UI controls, the control data is the data that actually represents the current value of the widget, which can be set and accessed with the `getValue()` and `setValue()` methods:
384
+
385
+
-`1` / `0` for toggle buttons
386
+
-`double` numbers for slider types
387
+
-`int` numbers for discrete widgets like combobox selectors.
388
+
389
+
Panels also support storing and getting their value with `setValue(value)` / `getValue()`, but as a panel is a generic control, this will not be reflected in any way on the UI. Also, panels have `saveInPreset` set to false by default. Enabling `saveInPreset` on a panel makes it useful as a place to persistently store objects, numbers, or booleans. Strings cannot be saved to Control Data, but can be encapsulated inside an object if circumstances require saving a persistent string.
390
+
391
+
Snippet demonstrating making a value persistent using a panel:
Calling `setValue(value)` does not execute the `onControl` callback (for safety reasons). Instead you need to explicitely tell the engine to fire the control callback using the method `Panel.changed()`
0 commit comments