SetOnMenuClickEventHandler

From GECK
Jump to: navigation, search


A function added by the JIP NVSE Plugin.

Description

Sets/removes the specified UDF Script as a handler that will be invoked in the event the specified UI Tile is clicked/pressed.


The tilePath argument may specify a menu name and target a specific tile by its <id> trait:

"InventoryMenu#8"

Note the menu name, immediately followed by a # symbol, then followed by a number matching the <id> trait of the tile. This is equivalent to "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_ButtonRect/IM_RepairButton".


The tilePath argument may be the full-path of a tile, such as:

"InventoryMenu/GLOW_BRANCH/IM_Tabline/Aid" (clicking on Aid tab)
"InventoryMenu/GLOW_BRANCH/IM_Tabline/Apparel" (clicking on Apparel tab)
"InventoryMenu/GLOW_BRANCH/IM_Tabline/Weapons" (clicking on Weapons tab)
"InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_InventoryList/IM_InventoryListTemplateRect" (clicking on any inventory item)

In the above cases the handler will be invoked only when the specific tile is clicked.


It may be a partial path, such as:

"InventoryMenu/GLOW_BRANCH/IM_Tabline"

In which case the handler will be invoked when ANY tile beginning with that path is clicked.


Note that the path, either full or partial, must begin with a valid menu name.


When invoked, the script is passed with three arguments:

  • (int) Menu Mode ID - 1002/1009/1075 etc.
  • (int) Tile ID - Only for tiles with a <id> property. Otherwise -1 is passed.
  • (string_var) Tile Name - Without the full-path, and in lower-case (for example: "apparel"). For template ListBox tiles, the name is suffixed with the tile's index in the list (for example: "stats_list_template_item:26")

Syntax

[help]
SetOnMenuClickEventHandler handlerScript:ref setORremove:1/0 tilePath:string

Example

SetOnMenuClickEventHandler OnMenuClickUDF 1 "ContainerMenu/NOGLOW_BRANCH/CM_ButtonRect/CM_ExitButton"

Sets the OnMenuClickUDF script as a handler to be invoked when any UI Tile(s) matching the string is clicked.

SetOnMenuClickEventHandler OnMenuClickUDF 0 "ContainerMenu/NOGLOW_BRANCH/CM_ButtonRect/CM_ExitButton"

Removes the OnMenuClickUDF script as a handler of the above.

Handler Script

A skeleton handler script for this event:

scn	OnMenuClickUDF

int	iMenuID
int	iTileID
string_var	sTileName

begin Function {iMenuID, iTileID, sTileName}

	(code)

	sv_Destruct sTileName

end

If using "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_InventoryList/IM_InventoryListTemplateRect" to detect inventory item clicks, the function GetSelectedItemRef can be used to retrieve the inventory item reference, the function GetBaseObject (GBO) can be used to get the base object from that reference, and the base object can be checked against an object category or a specific object with the functions GetType and/or GetIsID respectively.

See Also