Compound widgets - using variable of structure binding in event-action system

Problem description

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.

Workaround

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.

Sample

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.

  1. text output widget which displays the string of the application
  2. invisible widgets as transfer between structure binding and event action system
  3. structure binding of the text and the alarm flag
  4. the alarm flag is mapped to the invisible widget
  5. the event action system can react to the change in visibility of the widget.
  6. 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.

6 Likes

Great post!

I like to use the ImageList for all sorts of “workarounds” inside a compound widget.

!!!Disclaimer!!!
The examples below are to be used at your own risk since I can’t guarantee they will continue to work with future versions of mappView! :face_with_peeking_eye:

Bind a variable like a State or StatusID to it and assign Status Text, State Name, Images or make widget visible/invisible using Events and Actions.

Sometimes the DropDown or ListBox also work quite well, all depends on the source type and desired output format.

Using the DropDown widget which is assigned a dataCollection as compound widget input.

ListBox with initialized dataCollection. This reduces the number of EventHandlers when the input changes because you assign the selectedValue directly from the ListBox to the text output.

image

Another example how the ImageList can be used to transform the Integer based source value into a text output.

This is just an overview to provide some ideas when trying to workaround some current compound widget restrictions.