Disable double-click -> ESC translation for main menu
authorCraig Robbins <kde.psych@gmail.com>
Sat, 14 Mar 2015 09:55:35 +0000 (19:55 +1000)
committerCraig Robbins <kde.psych@gmail.com>
Sat, 14 Mar 2015 13:41:42 +0000 (23:41 +1000)
src/guiEngine.cpp
src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h

index dbb6fdf92396bdb0c5ba2927d5acc205012ba94a..30296b40c42a163c340357f9582276a6cc8c3e9a 100644 (file)
@@ -194,7 +194,8 @@ GUIEngine::GUIEngine(       irr::IrrlichtDevice* dev,
                        m_texture_source,
                        m_formspecgui,
                        m_buttonhandler,
-                       NULL);
+                       NULL,
+                       false);
 
        m_menu->allowClose(false);
        m_menu->lockSize(true,v2u32(800,600));
index d25b6cdf908b22930ed651666bc7a6ba2a7517da..11360a0fc4f3a92b4b23b77e8ecd7d3d0e2cbe4f 100644 (file)
@@ -77,7 +77,7 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
                gui::IGUIElement* parent, s32 id, IMenuManager *menumgr,
                InventoryManager *invmgr, IGameDef *gamedef,
                ISimpleTextureSource *tsrc, IFormSource* fsrc, TextDest* tdst,
-               Client* client) :
+               Client* client, bool remap_dbl_click) :
        GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr),
        m_device(dev),
        m_invmgr(invmgr),
@@ -97,7 +97,8 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
        m_text_dst(tdst),
        m_formspec_version(0),
        m_focused_element(L""),
-       m_font(NULL)
+       m_font(NULL),
+       m_remap_dbl_click(remap_dbl_click)
 #ifdef __ANDROID__
        ,m_JavaDialogFieldName(L"")
 #endif
@@ -2939,15 +2940,18 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event)
 bool GUIFormSpecMenu::DoubleClickDetection(const SEvent event)
 {
        /* The following code is for capturing double-clicks of the mouse button
-        * that are *not* in/in a control (i.e. when the mouse if positioned in an
-        * unused area of the formspec) and translating the double-click into an
-        * EET_KEY_INPUT_EVENT event which closes the form.
+        * and translating the double-click into an EET_KEY_INPUT_EVENT event
+        * -- which closes the form -- under some circumstances.
         *
         * There have been many github issues reporting this as a bug even though it
-        * was an intended feature.  For this reason the code has been disabled for
-        * non-Android builds
+        * was an intended feature.  For this reason, remapping the double-click as
+        * an ESC must be explicitly set when creating this class via the
+        * /p remap_dbl_click parameter of the constructor.
         */
-#ifdef __ANDROID__
+
+       if (!m_remap_dbl_click)
+               return false;
+
        if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
                m_doubleclickdetect[0].pos  = m_doubleclickdetect[1].pos;
                m_doubleclickdetect[0].time = m_doubleclickdetect[1].time;
@@ -2986,7 +2990,7 @@ bool GUIFormSpecMenu::DoubleClickDetection(const SEvent event)
                delete translated;
                return true;
        }
-#endif
+
        return false;
 }
 
index 2074fb780c7e71746197beaac8ba8f5326309c59..73dc7af62fce72336f3b3e162c05b5acfecc0c1e 100644 (file)
@@ -210,8 +210,8 @@ public:
                        ISimpleTextureSource *tsrc,
                        IFormSource* fs_src,
                        TextDest* txt_dst,
-                       Client* client
-                       );
+                       Client* client,
+                       bool remap_dbl_click = true);
 
        ~GUIFormSpecMenu();
 
@@ -436,6 +436,14 @@ private:
        std::wstring m_JavaDialogFieldName;
 #endif
 
+       /* If true, remap a double-click (or double-tap) action to ESC. This is so
+        * that, for example, Android users can double-tap to close a formspec.
+       *
+        * This value can (currently) only be set by the class constructor
+        * and the default value for the setting is true.
+        */
+       bool m_remap_dbl_click;
+
 };
 
 class FormspecFormSource: public IFormSource