no real changes, just some cleanup: add wxIsAltDown() in addition to the existing wxIsShift/CtrlDown() and wxIsAnyModifiedDown() to test for all of them at once (slightly modified patch 1833235)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-11-17 00:24:07 +00:00
parent d04a9fdfe2
commit 6719c06a97
4 changed files with 33 additions and 28 deletions

View 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
// get the current state of SHIFT/CTRL/ALT keys
inline bool wxIsModifierDown(int vk)
{
// GetKeyState() returns different negative values on WinME and WinNT,
// so simply test for negative value.
return ::GetKeyState(vk) < 0;
}
inline bool wxIsShiftDown()
{
// return (::GetKeyState(VK_SHIFT) & 0x100) != 0;
// Returns different negative values on WinME and WinNT,
// so simply test for negative value.
return ::GetKeyState(VK_SHIFT) < 0;
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

View 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);
}

View 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;

View 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;