]>
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 HasModifiers())
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 bool HasModifiers() const;
80 Returns true if the Control key or Apple/Command key under OS X is pressed.
82 This function doesn't distinguish between right and left control keys.
84 Notice that GetModifiers() should usually be used instead of this one.
86 bool ControlDown() const;
89 Returns true if the Control key (also under OS X).
91 This function doesn't distinguish between right and left control keys.
93 Notice that GetModifiers() should usually be used instead of this one.
95 bool RawControlDown() const;
98 Returns true if the Shift key is pressed.
100 This function doesn't distinguish between right and left shift keys.
102 Notice that GetModifiers() should usually be used instead of this one.
104 bool ShiftDown() const;
107 Returns true if the Meta/Windows/Apple key is pressed.
109 This function tests the state of the key traditionally called Meta
110 under Unix systems, Windows keys under MSW
111 Notice that GetModifiers() should usually be used instead of this one.
115 bool MetaDown() const;
118 Returns true if the Alt key is pressed.
120 Notice that GetModifiers() should usually be used instead of this one.
122 bool AltDown() const;
125 Returns true if the key used for command accelerators is pressed. Same as
126 ControlDown(). Deprecated.
128 Notice that GetModifiers() should usually be used instead of this one.
130 bool CmdDown() const;
133 void SetControlDown(bool down
);
134 void SetRawControlDown(bool down
);
135 void SetShiftDown(bool down
);
136 void SetAltDown(bool down
);
137 void SetMetaDown(bool down
);