summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@trolltech.com>2009-05-07 14:54:05 +0200
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-05-07 15:00:30 +0200
commit12348ea833bf731a0a977cd201d6804c6f3af221 (patch)
tree9f1ee1acf86a8cea1a365c02640ebf2636ac5cf7
parentf2fc8979cbeb732fe4799ec43d6d376aba0a87c9 (diff)
downloadqt4-tools-12348ea833bf731a0a977cd201d6804c6f3af221.tar.gz
handle the back soft key on Windows mobile SmartPhones
We must tell the system that we want to intercept the back key on Windows mobile. Each toplevel widget that needs correct back key behaviour needs to have a menu bar. Why? Ask Microsoft... Task-number: 248846 Reviewed-by: thartman
-rw-r--r--src/gui/kernel/qapplication_win.cpp15
-rw-r--r--src/gui/widgets/qmenu_wince.cpp16
2 files changed, 30 insertions, 1 deletions
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 065e7ff2d3..f14ad6ffa1 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1725,6 +1725,21 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// fall-through intended
case WM_KEYUP:
case WM_SYSKEYUP:
+#if Q_OS_WINCE_WM
+ case WM_HOTKEY:
+ if(HIWORD(msg.lParam) == VK_TBACK) {
+ const bool hotKeyDown = !(LOWORD(msg.lParam) & MOD_KEYUP);
+ msg.lParam = 0x69 << 16;
+ msg.wParam = VK_BACK;
+ if (hotKeyDown) {
+ msg.message = WM_KEYDOWN;
+ qt_keymapper_private()->updateKeyMap(msg);
+ } else {
+ msg.message = WM_KEYUP;
+ }
+ }
+ // fall-through intended
+#endif
case WM_IME_CHAR:
case WM_IME_KEYDOWN:
case WM_CHAR: {
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
index ea58d468ed..847a6234ec 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/gui/widgets/qmenu_wince.cpp
@@ -58,6 +58,9 @@
#include <QtCore/qlibrary.h>
#include <commctrl.h>
+#if Q_OS_WINCE_WM
+# include <windowsm.h>
+#endif
#include "qguifunctions_wince.h"
@@ -71,6 +74,12 @@
#define SHCMBM_GETSUBMENU (WM_USER + 401)
#endif
+#ifdef Q_OS_WINCE_WM
+# define SHMBOF_NODEFAULT 0x00000001
+# define SHMBOF_NOTIFY 0x00000002
+# define SHCMBM_OVERRIDEKEY (WM_USER + 0x193)
+#endif
+
extern bool qt_wince_is_smartphone();//defined in qguifunctions_wce.cpp
extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wce.cpp
@@ -204,8 +213,13 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i
mbi.dwFlags = flags;
mbi.nToolBarId = toolbarID;
- if (ptrCreateMenuBar(&mbi))
+ if (ptrCreateMenuBar(&mbi)) {
+ // Tell the menu bar that we want to override hot key behaviour.
+ LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
+ SHMBOF_NODEFAULT | SHMBOF_NOTIFY);
+ SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam);
return mbi.hwndMB;
+ }
}
return 0;
}