Skip to content

Commit

Permalink
Submit name of field on enter key press
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Aug 27, 2016
1 parent fb20b45 commit 4330c63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/guiFormSpecMenu.cpp
Expand Up @@ -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__
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/guiFormSpecMenu.h
Expand Up @@ -463,6 +463,7 @@ class GUIFormSpecMenu : public GUIModalMenu
} fs_key_pendig;

fs_key_pendig current_keys_pending;
std::string current_field_enter_pending;

void parseElement(parserData* data,std::string element);

Expand Down Expand Up @@ -557,4 +558,3 @@ class FormspecFormSource: public IFormSource
};

#endif

0 comments on commit 4330c63

Please sign in to comment.