From e0499731a867c76005f7cd83ee18c1a9503da719 Mon Sep 17 00:00:00 2001 From: v-rob Date: Sun, 12 Jul 2020 00:47:05 -0700 Subject: Allow FormSpec elements to be focused with `set_focus` (#9353) This allows you to specify a FormSpec element to set the focus of with "set_focus[;]". --- doc/lua_api.txt | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'doc/lua_api.txt') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 2ac4d6766..4e6983be8 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2492,7 +2492,7 @@ Elements * There are two ways to use it: 1. handle the changed event (only changed scrollbar is available) 2. read the value on pressing a button (all scrollbars are available) -* `orientation`: `vertical`/`horizontal` +* `orientation`: `vertical`/`horizontal`. Default horizontal. * Fieldname data is transferred to Lua * Value of this trackbar is set to (`0`-`1000`) by default * See also `minetest.explode_scrollbar_event` @@ -2606,6 +2606,28 @@ Elements * All provided states must be active for the style to apply. * See [Styling Formspecs]. +### `set_focus[;]` + +* Sets the focus to the element with the same `name` parameter. +* **Note**: This element must be placed before the element it focuses. +* `force` (optional, default `false`): By default, focus is not applied for + re-sent formspecs with the same name so that player-set focus is kept. + `true` sets the focus to the specified element for every sent formspec. +* The following elements have the ability to be focused: + * checkbox + * button + * button_exit + * image_button + * image_button_exit + * item_image_button + * table + * textlist + * dropdown + * field + * pwdfield + * textarea + * scrollbar + Migrating to Real Coordinates ----------------------------- @@ -4485,7 +4507,7 @@ Call these functions only at load time! * a button was pressed, * Enter was pressed while the focus was on a text field * a checkbox was toggled, - * something was selecteed in a drop-down list, + * something was selected in a dropdown list, * a different tab was selected, * selection was changed in a textlist or table, * an entry was double-clicked in a textlist or table, -- cgit v1.2.3