From 44353523d85ba44f62bad4ab7b27a14001d4b1ae Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Mar 2005 23:05:16 +0000 Subject: [PATCH] document (and check for it with assert) that wxGetKeyState(WXK_[LMR]BUTTON) doesn't work (patch 1156279) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32970 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/function.tex | 11 ++++++++--- src/mac/carbon/app.cpp | 3 +++ src/mac/classic/app.cpp | 3 +++ src/mac/corefoundation/hid.cpp | 3 +++ src/msw/window.cpp | 3 +++ src/unix/utilsx11.cpp | 3 +++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index da69c22a61..42069bf337 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -2660,9 +2660,14 @@ this language feature but still take advantage of it when it is available. \func{bool}{wxGetKeyState}{\param{wxKeyCode }{key}} -Returns \true if the key parameter is currently pressed on the keyboard, or -with modifier keys, (caps lock, etc) if the key is active (the led light is -on). +For normal keys, returns \true if the specified key is currently down. + +For togglable keys (Caps Lock, Num Lock and Scroll Lock), returns +\true if the key is toggled such that its LED indicator is lit. There is +currently no way to test whether togglable keys are up or down. + +Even though there are virtual key codes defined for mouse buttons, they +cannot be used with this function currently. \wxheading{Include files} diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index bcff118fb6..43c7cf1b29 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -1184,6 +1184,9 @@ int wxMacKeyCodeToModifier(wxKeyCode key) #ifndef __DARWIN__ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below { + wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != + WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); + //if OS X > 10.2 (i.e. 10.2.x) //a known apple bug prevents the system from determining led //states with GetKeys... can only determine caps lock led diff --git a/src/mac/classic/app.cpp b/src/mac/classic/app.cpp index d1267be385..c2aaf86cd0 100644 --- a/src/mac/classic/app.cpp +++ b/src/mac/classic/app.cpp @@ -1853,6 +1853,9 @@ int wxKeyCodeToMacModifier(wxKeyCode key) bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below { + wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != + WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); + #if __WXMAC_CARBON__ //TODO: Low get map... return !!(GetCurrentKeyModifiers() & wxKeyCodeToMacModifier(key)); diff --git a/src/mac/corefoundation/hid.cpp b/src/mac/corefoundation/hid.cpp index 16c956b207..f3e2f937f9 100644 --- a/src/mac/corefoundation/hid.cpp +++ b/src/mac/corefoundation/hid.cpp @@ -488,6 +488,9 @@ wxHIDKeyboard* wxHIDModule::sm_keyboard; bool wxGetKeyState (wxKeyCode key) { + wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != + WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); + if (!wxHIDModule::sm_keyboard) { wxHIDModule::sm_keyboard = new wxHIDKeyboard(); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index d196f61203..c332ba35ef 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -5144,6 +5144,9 @@ bool wxGetKeyState(wxKeyCode key) { bool bVirtual; + wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != + WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); + //High order with GetAsyncKeyState only available on WIN32 #ifdef __WIN32__ //If the requested key is a LED key, return diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index 8d400126c6..012b53114e 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -764,6 +764,9 @@ KeySym wxCharCodeWXToX(int id) bool wxGetKeyState(wxKeyCode key) { + wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != + WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); + #if defined(__WXX11__) Display *pDisplay = (Display*) wxApp::GetDisplay(); #elif defined(__WXGTK__) -- 2.45.2