rewrite wxGetKeyState a bit, spun from [ 1058347 ] Fixes wxGetKeyState

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30316 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ryan Norton
2004-11-06 06:41:05 +00:00
parent f1108504ce
commit 84c51ddf77

View File

@@ -5133,25 +5133,32 @@ WXWORD wxCharCodeWXToMSW(int id, bool *isVirtual)
bool wxGetKeyState(wxKeyCode key) bool wxGetKeyState(wxKeyCode key)
{ {
bool bVirtual; bool bVirtual;
WORD vkey = wxCharCodeWXToMSW(key, &bVirtual);
SHORT state;
switch (key) //High order with GetAsyncKeyState only available on WIN32
#ifdef __WIN32__
//If the requested key is a LED key, return
//true if the led is pressed
if (key == WXK_NUMLOCK ||
key == WXK_CAPITAL ||
key == WXK_SCROLL)
{ {
case WXK_NUMLOCK: #endif
case WXK_CAPITAL: //low order bit means LED is highlighted,
case WXK_SCROLL: //high order means key is down
// get the toggle state of the special key //Here, for compat with other ports we want both
state = GetKeyState(vkey); return GetKeyState( wxCharCodeWXToMSW(key, &bVirtual) ) != 0;
break;
default: #ifdef __WIN32__
// Get the current state of the physical key
state = GetAsyncKeyState(vkey);
break;
} }
// if the most significant bit is set then the key is down else
return ( state & 0x0001 ) != 0; {
//normal key
//low order bit means key pressed since last call
//high order means key is down
//We want only the high order bit - the key may not be down if only low order
return ( GetAsyncKeyState( wxCharCodeWXToMSW(key, &bVirtual) ) & (1<<15) ) != 0;
}
#endif
} }
wxWindow *wxGetActiveWindow() wxWindow *wxGetActiveWindow()