From: Vadim Zeitlin Date: Sun, 29 Jul 2012 22:08:09 +0000 (+0000) Subject: Revert HasModifiers() change in behaviour, add HasAnyModifiers(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/756ead6f83b2bc794aeb76755f5fe11fb3f11728 Revert HasModifiers() change in behaviour, add HasAnyModifiers(). In 2.8 wxKeyEvent::HasModifiers() returned false if (only) Shift was pressed as it tested for Control and Alt only but when it was moved to wxKeyboardState in r55745 it started checking for all modifiers as this made more sense now that it was used by wxMouseEvent. However it broke existing code using it, including in wxWidgets itself (in wxTreeCtrl), so revert it now and add HasAnyModifiers() that does check for all modifiers, including Shift. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72251 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/kbdstate.h b/include/wx/kbdstate.h index 25b660c0df..71e196db3c 100644 --- a/include/wx/kbdstate.h +++ b/include/wx/kbdstate.h @@ -55,7 +55,14 @@ public: } // returns true if any modifiers at all are pressed - bool HasModifiers() const { return GetModifiers() != wxMOD_NONE; } + bool HasAnyModifiers() const { return GetModifiers() != wxMOD_NONE; } + + // returns true if any modifiers changing the usual key interpretation are + // pressed, notably excluding Shift + bool HasModifiers() const + { + return ControlDown() || RawControlDown() || AltDown(); + } // accessors for individual modifier keys bool ControlDown() const { return m_controlDown; } diff --git a/interface/wx/kbdstate.h b/interface/wx/kbdstate.h index 4b85b6383a..c8d14bc8ad 100644 --- a/interface/wx/kbdstate.h +++ b/interface/wx/kbdstate.h @@ -41,7 +41,7 @@ public: The return value is a combination of @c wxMOD_ALT, @c wxMOD_CONTROL, @c wxMOD_SHIFT and @c wxMOD_META bit masks. Additionally, @c wxMOD_NONE - is defined as 0, i.e. corresponds to no modifiers (see HasModifiers()) + is defined as 0, i.e. corresponds to no modifiers (see HasAnyModifiers()) and @c wxMOD_CMD is either @c wxMOD_CONTROL (MSW and Unix) or @c wxMOD_META (Mac), see CmdDown(). See ::wxKeyModifier for the full list of modifiers. @@ -73,6 +73,27 @@ public: Returns true if any modifiers at all are pressed. This is equivalent to @c GetModifiers() @c != @c wxMOD_NONE. + + Notice that this is different from HasModifiers() method which doesn't + take e.g. Shift modifier into account. This method is most suitable for + mouse events when any modifier, including Shift, can change the + interpretation of the event. + + @since 2.9.5 + */ + bool HasAnyModifiers() const; + + /** + Returns true if Control or Alt are pressed. + + Checks if Control, Alt or, under OS X only, Command key are pressed + (notice that the real Control key is still taken into account under OS + X too). + + This method returns @false if only Shift is pressed for compatibility + reasons and also because pressing Shift usually doesn't change the + interpretation of key events, see HasAnyModifiers() if you want to + take Shift into account as well. */ bool HasModifiers() const;