summaryrefslogtreecommitdiff
path: root/src/guiFormSpecMenu.cpp
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-06-14 12:27:56 +0200
committersapier <Sapier at GMX dot net>2014-06-18 18:47:41 +0200
commit2a09b7e84fb5ce2d8d08d410529d70d440d48ef0 (patch)
tree13230c1a17e984c5950462e7136dd938a9d8201d /src/guiFormSpecMenu.cpp
parentce9f1e1d3cacb8e81436a63254cb1d70cad7a0ed (diff)
downloadminetest-2a09b7e84fb5ce2d8d08d410529d70d440d48ef0.tar.gz
minetest-2a09b7e84fb5ce2d8d08d410529d70d440d48ef0.tar.bz2
minetest-2a09b7e84fb5ce2d8d08d410529d70d440d48ef0.zip
Make dropdown formspec elements send their value same style as buttons on change
Diffstat (limited to 'src/guiFormSpecMenu.cpp')
-rw-r--r--src/guiFormSpecMenu.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp
index 48bdf2d50..c16600733 100644
--- a/src/guiFormSpecMenu.cpp
+++ b/src/guiFormSpecMenu.cpp
@@ -2723,8 +2723,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
return true;
}
}
- if((event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED) ||
- (event.GUIEvent.EventType==gui::EGET_CHECKBOX_CHANGED)) {
+ if((event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) ||
+ (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) ||
+ (event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED)) {
unsigned int btn_id = event.GUIEvent.Caller->getID();
if (btn_id == 257) {
@@ -2756,14 +2757,36 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
}
return true;
} else {
- acceptInput();
+ acceptInput(quit_mode_no);
s.send = false;
return true;
}
}
+ if ((s.ftype == f_DropDown) &&
+ (s.fid == event.GUIEvent.Caller->getID())) {
+ // only send the changed dropdown
+ for(u32 i=0; i<m_fields.size(); i++) {
+ FieldSpec &s2 = m_fields[i];
+ if (s2.ftype == f_DropDown) {
+ s2.send = false;
+ }
+ }
+ s.send = true;
+ acceptInput(quit_mode_no);
+
+ // revert configuration to make sure dropdowns are sent on
+ // regular button click
+ for(u32 i=0; i<m_fields.size(); i++) {
+ FieldSpec &s2 = m_fields[i];
+ if (s2.ftype == f_DropDown) {
+ s2.send = true;
+ }
+ }
+ return true;
+ }
}
}
- if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER) {
+ if(event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) {
if(event.GUIEvent.Caller->getID() > 257) {
if (m_allowclose) {
@@ -2778,7 +2801,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
}
}
- if(event.GUIEvent.EventType==gui::EGET_TABLE_CHANGED) {
+ if(event.GUIEvent.EventType == gui::EGET_TABLE_CHANGED) {
int current_id = event.GUIEvent.Caller->getID();
if(current_id > 257) {
// find the element that was clicked