diff options
author | rubenwardy <rubenwardy@gmail.com> | 2016-08-07 16:01:00 +0100 |
---|---|---|
committer | rubenwardy <rubenwardy@gmail.com> | 2016-08-27 13:02:45 +0100 |
commit | 4330c63ea40a75d4b8fcf71dc749fed714b22a44 (patch) | |
tree | 57f1373c539bdfa617dbd19f36f6b0412b1e0e5f /src | |
parent | fb20b45100490acd47038be43b6f257c1bd75d97 (diff) | |
download | minetest-4330c63ea40a75d4b8fcf71dc749fed714b22a44.tar.gz minetest-4330c63ea40a75d4b8fcf71dc749fed714b22a44.tar.bz2 minetest-4330c63ea40a75d4b8fcf71dc749fed714b22a44.zip |
Submit name of field on enter key press
Diffstat (limited to 'src')
-rw-r--r-- | src/guiFormSpecMenu.cpp | 13 | ||||
-rw-r--r-- | src/guiFormSpecMenu.h | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index a9cbb6254..dd96da5a9 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -104,6 +104,7 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev, m_formspec_version(0), m_focused_element(""), m_joystick(joystick), + current_field_enter_pending(""), m_font(NULL), m_remap_dbl_click(remap_dbl_click) #ifdef __ANDROID__ @@ -2695,6 +2696,10 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no) current_keys_pending.key_enter = false; } + if (!current_field_enter_pending.empty()) { + fields["key_enter_field"] = current_field_enter_pending; + } + if (current_keys_pending.key_escape) { fields["key_escape"] = "true"; current_keys_pending.key_escape = false; @@ -3625,8 +3630,16 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) if (event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) { if (event.GUIEvent.Caller->getID() > 257) { + for (u32 i = 0; i < m_fields.size(); i++) { + FieldSpec &s = m_fields[i]; + if (s.ftype == f_Unknown && + s.fid == event.GUIEvent.Caller->getID()) { + current_field_enter_pending = s.fname; + } + } if (m_allowclose) { + current_keys_pending.key_enter = true; acceptInput(quit_mode_accept); quitMenu(); } else { diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index 2fb55070d..7b809df71 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -463,6 +463,7 @@ private: } fs_key_pendig; fs_key_pendig current_keys_pending; + std::string current_field_enter_pending; void parseElement(parserData* data,std::string element); @@ -557,4 +558,3 @@ public: }; #endif - |