X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34621cc5d6eaf8933935fbda55625124429a0ff9..1d6560d796aefb5dbdf217109767b1054c68c291:/src/msw/window.cpp?ds=sidebyside diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 6f277cec40..bcba0c04c8 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4551,7 +4551,7 @@ wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType, event.m_eventObject = (wxWindow *)this; // const_cast event.m_keyCode = id; #if wxUSE_UNICODE - event.m_uniChar = wParam; + event.m_uniChar = (wxChar) wParam; #endif event.m_rawCode = (wxUint32) wParam; event.m_rawFlags = (wxUint32) lParam; @@ -5133,25 +5133,32 @@ WXWORD wxCharCodeWXToMSW(int id, bool *isVirtual) bool wxGetKeyState(wxKeyCode key) { 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: - case WXK_CAPITAL: - case WXK_SCROLL: - // get the toggle state of the special key - state = GetKeyState(vkey); - break; +#endif + //low order bit means LED is highlighted, + //high order means key is down + //Here, for compat with other ports we want both + return GetKeyState( wxCharCodeWXToMSW(key, &bVirtual) ) != 0; - default: - // Get the current state of the physical key - state = GetAsyncKeyState(vkey); - break; +#ifdef __WIN32__ } - // if the most significant bit is set then the key is down - return ( state & 0x0001 ) != 0; + else + { + //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()