1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

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[<name>;<always set>]".
This commit is contained in:
v-rob 2020-07-12 00:47:05 -07:00 committed by GitHub
parent d80def5bbf
commit e0499731a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 102 additions and 39 deletions

View file

@ -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[<name>;<force>]`
* 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,