Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WindowAssignFocus

From RoR Wiki

UI Lua API · Window functions
Version: WAR 1.4.8

Gives keyboard focus to a window, or takes it away.

WindowAssignFocus(windowName, focus)

Arguments

windowName
string – Name of the window, typically a TextEditBox.
focus
boolean – true to give the window focus, false to take it away.

Returns

Nothing.

Details

  • With true, the window must currently be drawn on screen. Show it (and its parents) first, otherwise the call raises the is not visible error.
  • With false, there is no visibility check.
  • focus must be a real boolean. Passing nil or a number raises an Invalid Parameters error.
  • The function needs at least two arguments and only reads the last two.

Errors

  • Error in function call 'WindowAssignFocus': Window %s does not exist
  • Error in function call 'WindowAssignFocus': Window %s is not visible. You may not set focus to a window that is not currently being drawn on the screen.
  • Error in function call 'WindowAssignFocus': Window %s is currently locked and may not be modified from lua. ...
    This check never triggers in the current client. See WindowSetShowing.

Example

Showing a text entry dialog and focusing its edit box, from easystem_dialogmanager/source/dialogmanager.lua:

-- Finally, show the dialog.
WindowSetShowing( "TextEntryDlg"..dlgIndex, true )
WindowAssignFocus( "TextEntryDlg"..dlgIndex.."TextEntry", true )
TextEditBoxSelectAll( "TextEntryDlg"..dlgIndex.."TextEntry" )

Releasing the focus when the dialog is closed, same file:

-- Ideally this should be done automatically when the window is hidden, but whatever.
WindowAssignFocus( "TextEntryDlg"..dlgIndex.."TextEntry", false )

See also