OAProfessor

Deep OA Product Insight

User Tools

Site Tools


graphics_ui_only_events

Most of the time the events created by the change of a DPE are enough for most designs. There are some interesting features that allow you to create an event that only the UI you are using will see.

Here is the scenario: You need to display output fields in the units (english vs. metric) that the user selects. You can imagine that the user would have some toggle button on a topology page like the info or navi page. If the user toggles this button, then all of the output fields on the page would change units and subsequent pages would also be in that units choice.

OA has a function call uiConnect which is similar to a dpConnect for a tag/DPE change, but it will execute on a UI trigger which you control when/how. This has a lot of parts to make it work, so I will try to give you one example.

#event This is a special statement that is only valid in the ScopeLib of a panel. For this example, let's put it on the navi panel of the topology thus making this event work on any panel displayed.

#event unitChange()                   // no ; this is the event name and it looks like a function

You will also want to set some global variable so that you can remember what units should be displayed for a new field because this event will only affect the fields that are visible. I recommend that you setup a manager global variable and use that on the init events of your output fields. In this same navi panel, you can have some code like this:

if(!globalExists("metricUnits"))
  addGlobal("metricUnits", BOOL_VAR);

triggerGlobalEvent Here is the call you need to make that will execute your event code. This would be attached to the button that toggles the units choice.

triggerGlobalEvent("unitChange");

When you trigger that event, you can then check the current units choice and toggle it.

metricUnits = !metricUnits;

uiConnect We have finally gotten to the magic of this solution. On the output field you will have probably 2 different events to setup:

  1. 1. dpConnect to know when to update the value in the field
  2. 2. uiConnect to know when to change the units for a value already in the field
  3. If you are clever, you can use the same code for both the sub routine of the dpConnect and the uiConnect!
uiConnect("updateValueField", "unitChange");

Now, in your function, you can check the global variable and know which unit conversion you might need.

void updateValueField()
{
  if(metricUnits)
    // run metric conversion if needed
  else
    // run english conversion if needed
}

There are other uiConnect methods and special calls. Check out the help for the latest: https://www.winccoa.com/documentation/WinCCOA/latest/en_US/ControlS_Z/uiConnect.html?hl=uiconnect

graphics_ui_only_events.txt · Last modified: by toddmalone

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki