User Tools

Site Tools


4rpl:commands:func_uicallback

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
4rpl:commands:func_uicallback [2021/01/14 15:46] – created virgilw4rpl:commands:func_uicallback [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 2: Line 2:
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
-_UICallback is invoked whenever a control panel UI element is changed. The control panel UI elements for a unit are part of its UI definitions in the CMod settings. Whenever a UI element is changed by the player, any script on the unit with :_UICallback (note the underscore) will have the function called.+====== :_UICallback ======
  
-There is an implicit variable named "_DATA" that is available for use when the callback is made. For this callback, _DATA is an int that points to the UI slot that was changed. 0 refers to the first slot, 1 the 2nd, etc.+===== Description =====
  
 +":_UICallback" is invoked whenever a control panel UI element is changed. The control panel UI elements for a unit are part of its UI definitions in the CMod settings. Whenever a UI element is changed by the player, any script on the unit with **:_UICallback** (note the underscore) will have the function called.
 +
 +There is an implicit variable named "_DATA" that is available for use when the callback is made. For this callback, **_DATA** is an int that points to the UI slot that was changed. 0 refers to the first slot, 1 the 2nd, etc.
 +
 +See: [[4rpl:commands:getunituistate|GetUnitUIState]] for further information
 +
 +===== Example =====
 +
 +<code 4rpl>
 +#:_UICALLBACK is called on any script (if present) whenever a UI widget is changed.
 +:_UICALLBACK
 +   #The _DATA is an int that points to the slot that was just changed
 +   GetUnitUIState(self <-_DATA) ->slotState
 +   printallsp("UICALLBACK: " <-slotState)
 +</code>
  
4rpl/commands/func_uicallback.1610639201.txt.gz · Last modified: 2025/02/14 14:56 (external edit)