From 56965bc81486b44bacf339785cc5d4376192c4ff Mon Sep 17 00:00:00 2001 From: Gregor Parzefall <82708541+grorp@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:20:50 +0200 Subject: [PATCH] Android: Add `field_enter_after_edit[]` formspec element (#13836) --- builtin/mainmenu/dlg_contentstore.lua | 2 +- builtin/mainmenu/settings/components.lua | 1 + builtin/mainmenu/settings/dlg_settings.lua | 1 + builtin/mainmenu/tab_online.lua | 1 + doc/lua_api.md | 22 ++++++++++--- .../devtest/mods/chest_of_everything/init.lua | 1 + src/gui/guiFormSpecMenu.cpp | 32 ++++++++++++++++++- src/gui/guiFormSpecMenu.h | 2 ++ src/network/networkprotocol.h | 2 +- 9 files changed, 56 insertions(+), 8 deletions(-) diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua index b66e98d57..73fc5fb0b 100644 --- a/builtin/mainmenu/dlg_contentstore.lua +++ b/builtin/mainmenu/dlg_contentstore.lua @@ -833,7 +833,7 @@ function store.get_formspec(dlgdata) "container[0.375,0.375]", "field[0,0;7.225,0.8;search_string;;", core.formspec_escape(search_string), "]", - "field_close_on_enter[search_string;false]", + "field_enter_after_edit[search_string;true]", "image_button[7.3,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "search.png"), ";search;]", "image_button[8.125,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "clear.png"), ";clear;]", "dropdown[9.175,0;2.7875,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]", diff --git a/builtin/mainmenu/settings/components.lua b/builtin/mainmenu/settings/components.lua index 5ae0cf567..51cc0c95b 100644 --- a/builtin/mainmenu/settings/components.lua +++ b/builtin/mainmenu/settings/components.lua @@ -84,6 +84,7 @@ local function make_field(converter, validator, stringifier) local fs = ("field[0,0.3;%f,0.8;%s;%s;%s]"):format( avail_w - 1.5, setting.name, get_label(setting), core.formspec_escape(value)) + fs = fs .. ("field_enter_after_edit[%s;true]"):format(setting.name) fs = fs .. ("button[%f,0.3;1.5,0.8;%s;%s]"):format(avail_w - 1.5, "set_" .. setting.name, fgettext("Set")) return fs, 1.1 diff --git a/builtin/mainmenu/settings/dlg_settings.lua b/builtin/mainmenu/settings/dlg_settings.lua index 0141adbc5..0b8628d81 100644 --- a/builtin/mainmenu/settings/dlg_settings.lua +++ b/builtin/mainmenu/settings/dlg_settings.lua @@ -477,6 +477,7 @@ local function get_formspec(dialogdata) "field[0.25,0.25;", tostring(search_width), ",0.75;search_query;;", core.formspec_escape(dialogdata.query or ""), "]", + "field_enter_after_edit[search_query;true]", "container[", tostring(search_width + 0.25), ", 0.25]", "image_button[0,0;0.75,0.75;", core.formspec_escape(defaulttexturedir .. "search.png"), ";search;]", "image_button[0.75,0;0.75,0.75;", core.formspec_escape(defaulttexturedir .. "clear.png"), ";search_clear;]", diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index cbe946c8b..5bf088d49 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -67,6 +67,7 @@ local function get_formspec(tabview, name, tabdata) local retval = -- Search "field[0.25,0.25;7,0.75;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" .. + "field_enter_after_edit[te_search;true]" .. "container[7.25,0.25]" .. "image_button[0,0;0.75,0.75;" .. core.formspec_escape(defaulttexturedir .. "search.png") .. ";btn_mp_search;]" .. "image_button[0.75,0;0.75,0.75;" .. core.formspec_escape(defaulttexturedir .. "clear.png") .. ";btn_mp_clear;]" .. diff --git a/doc/lua_api.md b/doc/lua_api.md index 17b6f0a1e..6d76981ef 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -2643,6 +2643,9 @@ Version History * Added padding[] element * Formspec version 6 (5.6.0): * Add nine-slice images, animated_image, and fgimg_middle +* Formspec version 7 (5.8.0): + * style[]: Add focused state for buttons + * Add field_enter_after_edit[] (experimental) Elements -------- @@ -2890,7 +2893,7 @@ Elements ### `pwdfield[,;,;;