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[;]". --- src/gui/guiFormSpecMenu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gui/guiFormSpecMenu.h') diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index a91afd2f7..19026bd34 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -168,6 +168,7 @@ public: { m_formspec_string = formspec_string; m_current_inventory_location = current_inventory_location; + m_is_form_regenerated = false; regenerateGui(m_screensize_old); } @@ -299,6 +300,10 @@ protected: std::string m_formspec_prepend; InventoryLocation m_current_inventory_location; + // Default true because we can't control regeneration on resizing, but + // we can control cases when the formspec is shown intentionally. + bool m_is_form_regenerated = true; + std::vector m_inventorylists; std::vector m_inventory_rings; std::vector m_backgrounds; @@ -339,10 +344,10 @@ protected: video::SColor m_default_tooltip_bgcolor; video::SColor m_default_tooltip_color; - private: IFormSource *m_form_src; TextDest *m_text_dst; + std::string m_last_formname; u16 m_formspec_version = 1; std::string m_focused_element = ""; JoystickController *m_joystick; @@ -359,7 +364,6 @@ private: core::rect rect; v2s32 basepos; v2u32 screensize; - std::string focused_fieldname; GUITable::TableOptions table_options; GUITable::TableColumns table_columns; gui::IGUIElement *current_parent = nullptr; @@ -439,6 +443,7 @@ private: bool parseAnchorDirect(parserData *data, const std::string &element); void parseAnchor(parserData *data, const std::string &element); bool parseStyle(parserData *data, const std::string &element, bool style_type); + void parseSetFocus(const std::string &element); void tryClose(); -- cgit v1.2.3