\member{bool}{m\_altDown}
+\textbf{Deprecated: } Please use \helpref{GetModifiers}{wxkeyeventgetmodifiers}
+instead!
+
true if the Alt key is pressed down.
\member{bool}{m\_controlDown}
+\textbf{Deprecated: } Please use \helpref{GetModifiers}{wxkeyeventgetmodifiers}
+instead!
+
true if control is pressed down.
\member{long}{m\_keyCode}
+\textbf{Deprecated: } Please use \helpref{GetKeyCode}{wxkeyeventgetkeycode}
+instead!
+
Virtual keycode. See \helpref{Keycodes}{keycodes} for a list of identifiers.
\member{bool}{m\_metaDown}
+\textbf{Deprecated: } Please use \helpref{GetModifiers}{wxkeyeventgetmodifiers}
+instead!
+
true if the Meta key is pressed down.
\member{bool}{m\_shiftDown}
+\textbf{Deprecated: } Please use \helpref{GetModifiers}{wxkeyeventgetmodifiers}
+instead!
+
true if shift is pressed down.
\member{int}{m\_x}
+\textbf{Deprecated: } Please use \helpref{GetX}{wxkeyeventgetx} instead!
+
X position of the event.
\member{int}{m\_y}
+\textbf{Deprecated: } Please use \helpref{GetY}{wxkeyeventgety} instead!
+
Y position of the event.
Returns true if the Alt key was down at the time of the key event.
+Notice that \helpref{GetModifiers}{wxkeyeventgetmodifiers} is easier to use
+correctly than this function so you should consider using it in new code.
+
\membersection{wxKeyEvent::CmdDown}\label{wxkeyeventcmddown}
\constfunc{bool}{CmdDown}{\void}
-"Cmd" is a pseudo key which is the same as Control for PC and Unix platforms
-but the special "Apple" (a.k.a as "Command") key under Macs: it makes often
-sense to use it instead of, say, ControlDown() because Cmd key is used for the
-same thing under Mac as Ctrl elsewhere (but Ctrl still exists, just not used
-for this purpose under Mac). So for non-Mac platforms this is the same as
-\helpref{ControlDown()}{wxkeyeventcontroldown} and under Mac this is the same
-as \helpref{MetaDown()}{wxkeyeventmetadown}.
+\textsc{Cmd} is a pseudo key which is the same as Control for PC and Unix
+platforms but the special \textsc{Apple} (a.k.a as \textsc{Command}) key under
+Macs: it makes often sense to use it instead of, say, ControlDown() because Cmd
+key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still
+exists, just not used for this purpose under Mac). So for non-Mac platforms
+this is the same as \helpref{ControlDown()}{wxkeyeventcontroldown} and under
+Mac this is the same as \helpref{MetaDown()}{wxkeyeventmetadown}.
\membersection{wxKeyEvent::ControlDown}\label{wxkeyeventcontroldown}
Returns true if the control key was down at the time of the key event.
+Notice that \helpref{GetModifiers}{wxkeyeventgetmodifiers} is easier to use
+correctly than this function so you should consider using it in new code.
+
\membersection{wxKeyEvent::GetKeyCode}\label{wxkeyeventgetkeycode}
\helpref{GetUnicodeKey}{wxkeyeventgetunicodekey}.
+\membersection{wxKeyEvent::GetModifiers}\label{wxkeyeventgetmodifiers}
+
+\constfunc{int}{GetModifiers}{\void}
+
+Return the bitmask of modifier keys which were pressed when this event
+happened. See \helpref{key modifier constants}{keymodifiers} for the full list
+of modifiers.
+
+Notice that this function is easier to use correctly than, for example,
+\helpref{ControlDown}{wxkeyeventcontroldown} because when using the latter you
+also have to remember to test that none of the other modifiers is pressed:
+
+\begin{verbatim}
+ if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() )
+ ... handle Ctrl-XXX ...
+\end{verbatim}
+
+and forgetting to do it can result in serious program bugs (e.g. program not
+working with European keyboard layout where \textsc{AltGr} key which is seen by
+the program as combination of \textsc{Ctrl} and \textsc{Alt} is used). On the
+other hand, you can simply write
+
+\begin{verbatim}
+ if ( GetModifiers() == wxMOD_CONTROL )
+ ... handle Ctrl-XXX ...
+\end{verbatim}
+
+with this function.
+
+
\membersection{wxKeyEvent::GetPosition}\label{wxkeyeventgetposition}
\constfunc{wxPoint}{GetPosition}{\void}
Returns true if the Meta key was down at the time of the key event.
+Notice that \helpref{GetModifiers}{wxkeyeventgetmodifiers} is easier to use
+correctly than this function so you should consider using it in new code.
+
\membersection{wxKeyEvent::ShiftDown}\label{wxkeyeventshiftdown}
Returns true if the shift key was down at the time of the key event.
+Notice that \helpref{GetModifiers}{wxkeyeventgetmodifiers} is easier to use
+correctly than this function so you should consider using it in new code.
+
--- /dev/null
+\section{Key Modifiers}\label{keymodifiers}
+
+\wxheading{Include files}
+
+<wx/defs.h>
+
+The following key modifier constants are defined:
+
+{\small
+\begin{verbatim}
+ enum wxKeyModifier
+ {
+ wxMOD_NONE = 0x0000,
+ wxMOD_ALT = 0x0001,
+ wxMOD_CONTROL = 0x0002,
+ wxMOD_ALTGR = wxMOD_ALT | wxMOD_CONTROL,
+ wxMOD_SHIFT = 0x0004,
+ wxMOD_META = 0x0008,
+ #if defined(__WXMAC__) || defined(__WXCOCOA__)
+ wxMOD_CMD = wxMOD_META,
+ #else
+ wxMOD_CMD = wxMOD_CONTROL,
+ #endif
+ wxMOD_ALL = 0xffff
+ };
+\end{verbatim}
+}
+
+Notice that \texttt{wxMOD\_CMD} should be used instead of
+\texttt{wxMOD\_CONTROL} in portable code to account for the fact that although
+\textsc{Control} modifier exists under Mac OS, it is not used for the same
+purpose as under Windows or Unix there while the special Mac-specific
+\textsc{Command} modifier is used in exactly the same way.
+
wxKeyEvent(wxEventType keyType = wxEVT_NULL);
wxKeyEvent(const wxKeyEvent& evt);
+ // can be used check if the key event has exactly the given modifiers:
+ // "GetModifiers() = wxMOD_CONTROL" is easier to write than "ControlDown()
+ // && !MetaDown() && !AltDown() && !ShiftDown()"
+ int GetModifiers() const
+ {
+ return (m_controlDown ? wxMOD_CONTROL : 0) |
+ (m_shiftDown ? wxMOD_SHIFT : 0) |
+ (m_metaDown ? wxMOD_META : 0) |
+ (m_altDown ? wxMOD_ALT : 0);
+ }
+
// Find state of shift/control keys
bool ControlDown() const { return m_controlDown; }
+ bool ShiftDown() const { return m_shiftDown; }
bool MetaDown() const { return m_metaDown; }
bool AltDown() const { return m_altDown; }
- bool ShiftDown() const { return m_shiftDown; }
// "Cmd" is a pseudo key which is Control for PC and Unix platforms but
// Apple ("Command") key under Macs: it makes often sense to use it instead
long m_keyCode;
+ // TODO: replace those with a single m_modifiers bitmask of wxMOD_XXX?
bool m_controlDown;
bool m_shiftDown;
bool m_altDown;
bool m_metaDown;
+
+ // FIXME: what is this for? relation to m_rawXXX?
bool m_scanCode;
#if wxUSE_UNICODE