API:LCDSetButtonHandler
From RoR Wiki
UI Lua API · LCD functions
Version: WAR 1.4.8
Registers a Lua function that an LCD page calls when one of the LCD's four soft buttons is pressed or released.
LCDSetButtonHandler(pageName, callbackName)
Arguments
- pageName
string– Name of the page.- callbackName
string– Name of the Lua function to call, for example"EA_LCDKeyboard.HandleLCDButton".
Returns
Nothing.
Details
- The handler is called as
callback(button, down):button(number) – the soft button, 1 to 4.down(boolean) –truewhen the button is pressed,falsewhen it is released.
- Each page can have one button handler. If the page already has one, the error below is logged and the old handler stays. Remove it first with LCDUnsetButtonHandler.
- The function needs at least two arguments and only reads the last two.
Errors
Error in function call 'LCDSetButtonHandler': Page '%s' does not exist.Error in function call 'LCDSetButtonHandler': Page %s already has an button press handler (%s).
Example
From ea_lcdkeyboard/source/g15test.lua, which gives every page the same handler:
LCDSetButtonHandler( EA_LCDKeyboard.Page0, "EA_LCDKeyboard.HandleLCDButton" ) LCDSetButtonHandler( EA_LCDKeyboard.Page1, "EA_LCDKeyboard.HandleLCDButton" ) function EA_LCDKeyboard.HandleLCDButton(button, down) if( down ) then if( button == 1 ) then LCDShowPage( EA_LCDKeyboard.Page1 ) end -- ...
