]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/kbdstate.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation of wxKeyboardState
4 // Author: wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 Provides methods for testing the state of the keyboard modifier keys.
13 This class is used as a base class of wxKeyEvent and wxMouseState and,
14 hence, indirectly, of wxMouseEvent, so its methods may be used to get
15 information about the modifier keys which were pressed when the event
18 This class is implemented entirely inline in @<wx/kbdstate.h@> and thus has
19 no linking requirements.
24 @see wxKeyEvent, wxMouseState
30 Constructor initializes the modifier key settings.
32 By default, no modifiers are active.
34 wxKeyboardState(bool controlDown
= false,
35 bool shiftDown
= false,
37 bool metaDown
= false);
40 Return the bit mask of all pressed modifier keys.
42 The return value is a combination of @c wxMOD_ALT, @c wxMOD_CONTROL,
43 @c wxMOD_SHIFT and @c wxMOD_META bit masks. Additionally, @c wxMOD_NONE
44 is defined as 0, i.e. corresponds to no modifiers (see HasAnyModifiers())
45 and @c wxMOD_CMD is either @c wxMOD_CONTROL (MSW and Unix) or
46 @c wxMOD_META (Mac), see CmdDown().
47 See ::wxKeyModifier for the full list of modifiers.
49 Notice that this function is easier to use correctly than, for example,
50 ControlDown() because when using the latter you also have to remember to
51 test that none of the other modifiers is pressed:
54 if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() )
55 ... handle Ctrl-XXX ...
58 and forgetting to do it can result in serious program bugs (e.g. program
59 not working with European keyboard layout where @c AltGr key which is
60 seen by the program as combination of CTRL and ALT is used). On the
61 other hand, you can simply write:
64 if ( GetModifiers() == wxMOD_CONTROL )
65 ... handle Ctrl-XXX ...
70 int GetModifiers() const;
73 Returns true if any modifiers at all are pressed.
75 This is equivalent to @c GetModifiers() @c != @c wxMOD_NONE.
77 Notice that this is different from HasModifiers() method which doesn't
78 take e.g. Shift modifier into account. This method is most suitable for
79 mouse events when any modifier, including Shift, can change the
80 interpretation of the event.
84 bool HasAnyModifiers() const;
87 Returns true if Control or Alt are pressed.
89 Checks if Control, Alt or, under OS X only, Command key are pressed
90 (notice that the real Control key is still taken into account under OS
93 This method returns @false if only Shift is pressed for compatibility
94 reasons and also because pressing Shift usually doesn't change the
95 interpretation of key events, see HasAnyModifiers() if you want to
96 take Shift into account as well.
98 bool HasModifiers() const;
101 Returns true if the Control key or Apple/Command key under OS X is pressed.
103 This function doesn't distinguish between right and left control keys.
105 Notice that GetModifiers() should usually be used instead of this one.
107 bool ControlDown() const;
110 Returns true if the Control key (also under OS X).
112 This function doesn't distinguish between right and left control keys.
114 Notice that GetModifiers() should usually be used instead of this one.
116 bool RawControlDown() const;
119 Returns true if the Shift key is pressed.
121 This function doesn't distinguish between right and left shift keys.
123 Notice that GetModifiers() should usually be used instead of this one.
125 bool ShiftDown() const;
128 Returns true if the Meta/Windows/Apple key is pressed.
130 This function tests the state of the key traditionally called Meta
131 under Unix systems, Windows keys under MSW
132 Notice that GetModifiers() should usually be used instead of this one.
136 bool MetaDown() const;
139 Returns true if the Alt key is pressed.
141 Notice that GetModifiers() should usually be used instead of this one.
143 bool AltDown() const;
146 Returns true if the key used for command accelerators is pressed. Same as
147 ControlDown(). Deprecated.
149 Notice that GetModifiers() should usually be used instead of this one.
151 bool CmdDown() const;
154 void SetControlDown(bool down
);
155 void SetRawControlDown(bool down
);
156 void SetShiftDown(bool down
);
157 void SetAltDown(bool down
);
158 void SetMetaDown(bool down
);