]> git.saurik.com Git - wxWidgets.git/commitdiff
no real changes, just some cleanup: add wxIsAltDown() in addition to the existing...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 17 Nov 2007 00:24:07 +0000 (00:24 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 17 Nov 2007 00:24:07 +0000 (00:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private.h
src/msw/listctrl.cpp
src/msw/treectrl.cpp
src/msw/window.cpp

index 262fc9ff80520d9a7661f237aac0fd63797c7826..da4b7e83caced8a5ebf2725f043fb3d5c794884d 100644 (file)
@@ -311,21 +311,32 @@ HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY);
     #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
 #endif // GET_X_LPARAM
 
-// get the current state of SHIFT/CTRL keys
-inline bool wxIsShiftDown()
+// get the current state of SHIFT/CTRL/ALT keys
+inline bool wxIsModifierDown(int vk)
 {
-//    return (::GetKeyState(VK_SHIFT) & 0x100) != 0;
-    // Returns different negative values on WinME and WinNT,
+    // GetKeyState() returns different negative values on WinME and WinNT,
     // so simply test for negative value.
-    return ::GetKeyState(VK_SHIFT) < 0;
+    return ::GetKeyState(vk) < 0;
+}
+
+inline bool wxIsShiftDown()
+{
+    return wxIsModifierDown(VK_SHIFT);
 }
 
 inline bool wxIsCtrlDown()
 {
-//    return (::GetKeyState(VK_CONTROL) & 0x100) != 0;
-    // Returns different negative values on WinME and WinNT,
-    // so simply test for negative value.
-    return ::GetKeyState(VK_CONTROL) < 0;
+    return wxIsModifierDown(VK_CONTROL);
+}
+
+inline bool wxIsAltDown()
+{
+    return wxIsModifierDown(VK_MENU);
+}
+
+inline bool wxIsAnyModifierDown()
+{
+    return wxIsShiftDown() || wxIsCtrlDown() || wxIsAltDown();
 }
 
 // wrapper around GetWindowRect() and GetClientRect() APIs doing error checking
index 1f67a95bbcd4ba03ae37bf88760a882e87d8440e..281d6c9efb1c9978a4288b62642d5fd74a544be2 100644 (file)
@@ -1806,17 +1806,14 @@ bool wxListCtrl::MSWShouldPreProcessMessage(WXMSG* msg)
 {
     if ( msg->message == WM_KEYDOWN )
     {
-        if ( msg->wParam == VK_RETURN )
+        // Only eat VK_RETURN if not being used by the application in
+        // conjunction with modifiers
+        if ( msg->wParam == VK_RETURN && !wxIsAnyModifierDown() )
         {
-            // We need VK_RETURN to generate wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
-            // but only if none of the modifiers is down.  We'll let normal
-            // accelerators handle those.
-            if ( !wxIsCtrlDown() && !wxIsCtrlDown() &&
-                 !((HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN))
+            // we need VK_RETURN to generate wxEVT_COMMAND_LIST_ITEM_ACTIVATED
             return false;
         }
     }
-
     return wxControl::MSWShouldPreProcessMessage(msg);
 }
 
index 20d027fbcd60d9b24aea1a467bfad7a9e982659c..63019b5e227dc74629609911ebb87b28446d3720 100644 (file)
@@ -1948,11 +1948,9 @@ bool wxTreeCtrl::MSWShouldPreProcessMessage(WXMSG* msg)
 {
     if ( msg->message == WM_KEYDOWN )
     {
-        const bool isAltDown = ::GetKeyState(VK_MENU) < 0;
-
-        // Only eat VK_RETURN if not being used by the application in conjunction with
-        // modifiers
-        if ( msg->wParam == VK_RETURN && !wxIsCtrlDown() && !wxIsShiftDown() && !isAltDown)
+        // Only eat VK_RETURN if not being used by the application in
+        // conjunction with modifiers
+        if ( (msg->wParam == VK_RETURN) && !wxIsAnyModifierDown() )
         {
             // we need VK_RETURN to generate wxEVT_COMMAND_TREE_ITEM_ACTIVATED
             return false;
@@ -2607,8 +2605,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                 // fabricate the lParam and wParam parameters sufficiently
                 // similar to the ones from a "real" WM_KEYDOWN so that
                 // CreateKeyEvent() works correctly
-                const bool isAltDown = ::GetKeyState(VK_MENU) < 0;
-                WXLPARAM lParam = (isAltDown ? KF_ALTDOWN : 0) << 16;
+                WXLPARAM lParam = (wxIsAltDown() ? KF_ALTDOWN : 0) << 16;
 
                 WXWPARAM wParam = info->wVKey;
 
@@ -2626,7 +2623,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                                                 wParam);
 
                 // a separate event for Space/Return
-                if ( !wxIsCtrlDown() && !wxIsShiftDown() && !isAltDown &&
+                if ( !wxIsAnyModifierDown() &&
                      ((info->wVKey == VK_SPACE) || (info->wVKey == VK_RETURN)) )
                 {
                    wxTreeItemId item;
index dbf35ef99914561611aa03b9050113d4f18cc513..d8be1a890be8f0ba2332ef232eaccf256994497b 100644 (file)
@@ -5020,7 +5020,7 @@ void wxWindowMSW::InitMouseEvent(wxMouseEvent& event,
     event.m_aux1Down = (flags & MK_XBUTTON1) != 0;
     event.m_aux2Down = (flags & MK_XBUTTON2) != 0;
 #endif // wxHAS_XBUTTON
-    event.m_altDown = ::GetKeyState(VK_MENU) < 0;
+    event.m_altDown = ::wxIsAltDown();
 
 #ifndef __WXWINCE__
     event.SetTimestamp(::GetMessageTime());
@@ -6061,9 +6061,9 @@ wxMouseState wxGetMouseState()
     ms.SetAux2Down(wxIsKeyDown(VK_XBUTTON2));
 #endif // wxHAS_XBUTTON
 
-    ms.SetControlDown(wxIsKeyDown(VK_CONTROL));
-    ms.SetShiftDown(wxIsKeyDown(VK_SHIFT));
-    ms.SetAltDown(wxIsKeyDown(VK_MENU));
+    ms.SetControlDown(wxIsCtrlDown ());
+    ms.SetShiftDown  (wxIsShiftDown());
+    ms.SetAltDown    (wxIsAltDown  ());
 //    ms.SetMetaDown();
 
     return ms;