Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:LCDSetButtonHandler

From RoR Wiki
Revision as of 19:46, 16 October 2026 by Maintenance script (talk | contribs) (UI Lua API import (WAR 1.4.8))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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) – true when the button is pressed, false when 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
		-- ...

See also