Skip to content

Commit de6d5ce

Browse files
committedMar 14, 2015
Disable double-click -> ESC translation for main menu
1 parent 0e93eef commit de6d5ce

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed
 

Diff for: ‎src/guiEngine.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
194194
m_texture_source,
195195
m_formspecgui,
196196
m_buttonhandler,
197-
NULL);
197+
NULL,
198+
false);
198199

199200
m_menu->allowClose(false);
200201
m_menu->lockSize(true,v2u32(800,600));

Diff for: ‎src/guiFormSpecMenu.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
7777
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr,
7878
InventoryManager *invmgr, IGameDef *gamedef,
7979
ISimpleTextureSource *tsrc, IFormSource* fsrc, TextDest* tdst,
80-
Client* client) :
80+
Client* client, bool remap_dbl_click) :
8181
GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr),
8282
m_device(dev),
8383
m_invmgr(invmgr),
@@ -97,7 +97,8 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
9797
m_text_dst(tdst),
9898
m_formspec_version(0),
9999
m_focused_element(L""),
100-
m_font(NULL)
100+
m_font(NULL),
101+
m_remap_dbl_click(remap_dbl_click)
101102
#ifdef __ANDROID__
102103
,m_JavaDialogFieldName(L"")
103104
#endif
@@ -2939,15 +2940,18 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event)
29392940
bool GUIFormSpecMenu::DoubleClickDetection(const SEvent event)
29402941
{
29412942
/* The following code is for capturing double-clicks of the mouse button
2942-
* that are *not* in/in a control (i.e. when the mouse if positioned in an
2943-
* unused area of the formspec) and translating the double-click into an
2944-
* EET_KEY_INPUT_EVENT event which closes the form.
2943+
* and translating the double-click into an EET_KEY_INPUT_EVENT event
2944+
* -- which closes the form -- under some circumstances.
29452945
*
29462946
* There have been many github issues reporting this as a bug even though it
2947-
* was an intended feature. For this reason the code has been disabled for
2948-
* non-Android builds
2947+
* was an intended feature. For this reason, remapping the double-click as
2948+
* an ESC must be explicitly set when creating this class via the
2949+
* /p remap_dbl_click parameter of the constructor.
29492950
*/
2950-
#ifdef __ANDROID__
2951+
2952+
if (!m_remap_dbl_click)
2953+
return false;
2954+
29512955
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
29522956
m_doubleclickdetect[0].pos = m_doubleclickdetect[1].pos;
29532957
m_doubleclickdetect[0].time = m_doubleclickdetect[1].time;
@@ -2986,7 +2990,7 @@ bool GUIFormSpecMenu::DoubleClickDetection(const SEvent event)
29862990
delete translated;
29872991
return true;
29882992
}
2989-
#endif
2993+
29902994
return false;
29912995
}
29922996

Diff for: ‎src/guiFormSpecMenu.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ class GUIFormSpecMenu : public GUIModalMenu
210210
ISimpleTextureSource *tsrc,
211211
IFormSource* fs_src,
212212
TextDest* txt_dst,
213-
Client* client
214-
);
213+
Client* client,
214+
bool remap_dbl_click = true);
215215

216216
~GUIFormSpecMenu();
217217

@@ -436,6 +436,14 @@ class GUIFormSpecMenu : public GUIModalMenu
436436
std::wstring m_JavaDialogFieldName;
437437
#endif
438438

439+
/* If true, remap a double-click (or double-tap) action to ESC. This is so
440+
* that, for example, Android users can double-tap to close a formspec.
441+
*
442+
* This value can (currently) only be set by the class constructor
443+
* and the default value for the setting is true.
444+
*/
445+
bool m_remap_dbl_click;
446+
439447
};
440448

441449
class FormspecFormSource: public IFormSource

0 commit comments

Comments
 (0)
Please sign in to comment.