triggerGlobalEvent()

The function triggers a UI global event.

Synopsis

int triggerGlobalEvent(string event, ...);

Parameters

Parameter Description
event Name of the event that is triggered.
... Arguments that are expected by the event.

Return value

-1 in case of an error and 0 in case of success.

Errors

Missing or incorrect arguments.

Description

The function triggerGlobalEvent() allows to trigger a specific UI global event inside of your code. This event can afterwards be used to connect to it using the function uiConnect().

To see all currently connected events the UI manager parameter "-report UI" can be used.

If a global event is no longer connected by anyone, it is internally removed and will no longer be displayed within the report output. If a script triggers an event to which no-one is connected, the event is simply ignored.

Example

In the example below the PushButton1 is used to connect or disconnect to the event "myGlobalEvent". Please note that the button property "Togglebutton" must be set to "TRUE" inside of the GEDI for the Pushbutton1.

Using the PushButton2 the event "myGlobalEvent" is triggered and the parameters "arg1 and arg2 are forwarded to the callback function "myCallback".

PushButton1 - Clicked Event
main(mapping event)
{
  string eventName = "myGlobalEvent";
  if(this.toggleState)
  {
    uiConnect("myCallback", eventName);
    DebugN("Connect - " + eventName);
  }
  else
  {
    uiDisconnect("myCallback", eventName);
    DebugN("Disconnect - " + eventName);
  }
}
myCallback(anytype arg1, anytype arg2)
{
  DebugN("Callback triggered!");
  DebugN("First Argument: " + arg1);
  DebugN("Second Argument: " + arg2);
}
PushButton2 - Clicked Event
main(mapping event)
{
  triggerGlobalEvent("myGlobalEvent", "myArg1", "myArg2");
}

Assignment

OOP

Availability

CTRL

Return value

triggerEvent(), triggerEventWait(), uiConnect()