Skip to content

Commit 4330c63

Browse files
committedAug 27, 2016
Submit name of field on enter key press
1 parent fb20b45 commit 4330c63

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎src/guiFormSpecMenu.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
104104
m_formspec_version(0),
105105
m_focused_element(""),
106106
m_joystick(joystick),
107+
current_field_enter_pending(""),
107108
m_font(NULL),
108109
m_remap_dbl_click(remap_dbl_click)
109110
#ifdef __ANDROID__
@@ -2695,6 +2696,10 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
26952696
current_keys_pending.key_enter = false;
26962697
}
26972698

2699+
if (!current_field_enter_pending.empty()) {
2700+
fields["key_enter_field"] = current_field_enter_pending;
2701+
}
2702+
26982703
if (current_keys_pending.key_escape) {
26992704
fields["key_escape"] = "true";
27002705
current_keys_pending.key_escape = false;
@@ -3625,8 +3630,16 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
36253630

36263631
if (event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) {
36273632
if (event.GUIEvent.Caller->getID() > 257) {
3633+
for (u32 i = 0; i < m_fields.size(); i++) {
3634+
FieldSpec &s = m_fields[i];
3635+
if (s.ftype == f_Unknown &&
3636+
s.fid == event.GUIEvent.Caller->getID()) {
3637+
current_field_enter_pending = s.fname;
3638+
}
3639+
}
36283640

36293641
if (m_allowclose) {
3642+
current_keys_pending.key_enter = true;
36303643
acceptInput(quit_mode_accept);
36313644
quitMenu();
36323645
} else {

‎src/guiFormSpecMenu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ class GUIFormSpecMenu : public GUIModalMenu
463463
} fs_key_pendig;
464464

465465
fs_key_pendig current_keys_pending;
466+
std::string current_field_enter_pending;
466467

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

@@ -557,4 +558,3 @@ class FormspecFormSource: public IFormSource
557558
};
558559

559560
#endif
560-

0 commit comments

Comments
 (0)
Please sign in to comment.