diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/guiFormSpecMenu.cpp | 28 | ||||
-rw-r--r-- | src/guiFormSpecMenu.h | 12 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index dd96da5a9..2564671a3 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -894,8 +894,8 @@ void GUIFormSpecMenu::parsePwdField(parserData* data,std::string element) { std::vector<std::string> parts = split(element,';'); - if ((parts.size() == 4) || - ((parts.size() > 4) && (m_formspec_version > FORMSPEC_API_VERSION))) + if ((parts.size() == 4) || (parts.size() == 5) || + ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION))) { std::vector<std::string> v_pos = split(parts[0],','); std::vector<std::string> v_geom = split(parts[1],','); @@ -952,6 +952,11 @@ void GUIFormSpecMenu::parsePwdField(parserData* data,std::string element) evt.KeyInput.Shift = 0; evt.KeyInput.PressedDown = true; e->OnEvent(evt); + + if (parts.size() >= 5 && !is_yes(parts[4])) { + spec.close_on_enter = false; + } + m_fields.push_back(spec); return; } @@ -1033,6 +1038,10 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data, } } + if (parts.size() >= 4 && !is_yes(parts[3])) { + spec.close_on_enter = false; + } + m_fields.push_back(spec); } @@ -1137,6 +1146,11 @@ void GUIFormSpecMenu::parseTextArea(parserData* data, addStaticText(Environment, spec.flabel.c_str(), rect, false, true, this, 0); } } + + if (parts.size() >= 6 && !is_yes(parts[5])) { + spec.close_on_enter = false; + } + m_fields.push_back(spec); } @@ -1150,8 +1164,8 @@ void GUIFormSpecMenu::parseField(parserData* data,std::string element, return; } - if ((parts.size() == 5) || - ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION))) + if ((parts.size() == 5) || (parts.size() == 6) || + ((parts.size() > 6) && (m_formspec_version > FORMSPEC_API_VERSION))) { parseTextArea(data,parts,type); return; @@ -2698,6 +2712,7 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no) if (!current_field_enter_pending.empty()) { fields["key_enter_field"] = current_field_enter_pending; + current_field_enter_pending = ""; } if (current_keys_pending.key_escape) { @@ -3630,15 +3645,18 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) if (event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) { if (event.GUIEvent.Caller->getID() > 257) { + bool close_on_enter = true; 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; + close_on_enter = s.close_on_enter; + break; } } - if (m_allowclose) { + if (m_allowclose && close_on_enter) { current_keys_pending.key_enter = true; acceptInput(quit_mode_accept); quitMenu(); diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index 7b809df71..d06aa6cf5 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -202,20 +202,22 @@ class GUIFormSpecMenu : public GUIModalMenu FieldSpec(const std::string &name, const std::wstring &label, const std::wstring &default_text, int id) : fname(name), - fid(id) + flabel(label), + fid(id), + send(false), + close_on_enter(false), + ftype(f_Unknown), + is_exit(false) { //flabel = unescape_enriched(label); - flabel = label; fdefault = unescape_enriched(default_text); - send = false; - ftype = f_Unknown; - is_exit = false; } std::string fname; std::wstring flabel; std::wstring fdefault; int fid; bool send; + bool close_on_enter; // used by text fields FormspecFieldType ftype; bool is_exit; core::rect<s32> rect; |