Skip to content

Commit 2a09b7e

Browse files
sapiersapier
sapier
authored and
sapier
committedJun 18, 2014
Make dropdown formspec elements send their value same style as buttons on change
1 parent ce9f1e1 commit 2a09b7e

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed
 

‎src/guiFormSpecMenu.cpp

+28-5
Original file line numberDiff line numberDiff line change
@@ -2723,8 +2723,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
27232723
return true;
27242724
}
27252725
}
2726-
if((event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED) ||
2727-
(event.GUIEvent.EventType==gui::EGET_CHECKBOX_CHANGED)) {
2726+
if((event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) ||
2727+
(event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) ||
2728+
(event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED)) {
27282729
unsigned int btn_id = event.GUIEvent.Caller->getID();
27292730

27302731
if (btn_id == 257) {
@@ -2756,14 +2757,36 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
27562757
}
27572758
return true;
27582759
} else {
2759-
acceptInput();
2760+
acceptInput(quit_mode_no);
27602761
s.send = false;
27612762
return true;
27622763
}
27632764
}
2765+
if ((s.ftype == f_DropDown) &&
2766+
(s.fid == event.GUIEvent.Caller->getID())) {
2767+
// only send the changed dropdown
2768+
for(u32 i=0; i<m_fields.size(); i++) {
2769+
FieldSpec &s2 = m_fields[i];
2770+
if (s2.ftype == f_DropDown) {
2771+
s2.send = false;
2772+
}
2773+
}
2774+
s.send = true;
2775+
acceptInput(quit_mode_no);
2776+
2777+
// revert configuration to make sure dropdowns are sent on
2778+
// regular button click
2779+
for(u32 i=0; i<m_fields.size(); i++) {
2780+
FieldSpec &s2 = m_fields[i];
2781+
if (s2.ftype == f_DropDown) {
2782+
s2.send = true;
2783+
}
2784+
}
2785+
return true;
2786+
}
27642787
}
27652788
}
2766-
if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER) {
2789+
if(event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) {
27672790
if(event.GUIEvent.Caller->getID() > 257) {
27682791

27692792
if (m_allowclose) {
@@ -2778,7 +2801,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
27782801
}
27792802
}
27802803

2781-
if(event.GUIEvent.EventType==gui::EGET_TABLE_CHANGED) {
2804+
if(event.GUIEvent.EventType == gui::EGET_TABLE_CHANGED) {
27822805
int current_id = event.GUIEvent.Caller->getID();
27832806
if(current_id > 257) {
27842807
// find the element that was clicked

0 commit comments

Comments
 (0)
Please sign in to comment.