Structure bindings offer an easy way to connect data with compound widgets. One problem, however, is that such structure bindings cannot be accessed in the event action system of the compound widget.
A binding to a local property can be made for individual variables, but this is not possible for structure bindings.
In order to still be able to react to values or value changes, the data of the structure binding can be mapped to invisible widgets (size 0 or visible = false) and then accessed from the event action system.
The aim of the sample below is to provide a text output with an alarm flag, which can be linked via a structure. If the flag is set in the application, the style is switched. Without this workaround, 2 bindings would be necessary here.
- text output widget which displays the string of the application
- invisible widgets as transfer between structure binding and event action system
- structure binding of the text and the alarm flag
- the alarm flag is mapped to the invisible widget
- the event action system can react to the change in visibility of the widget.
- if the visibility of the widget has changed, this means that the bool in the application has changed and the style can be changed.
This is just a simple sample which shows to react to a boolean change. Similar use cases are also conceivable with value changes or other events.