]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/kbdstate.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     documentation of wxKeyboardState 
   4 // Author:      wxWidgets team 
   7 // Licence:     wxWindows license 
   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/keystate.h@> and thus has 
  19     no linking requirements. 
  23     @see wxKeyEvent, wxMouseState 
  29         Constructor initializes the modifier key settings. 
  31         By default, no modifiers are active. 
  33     wxKeyboardState(bool controlDown 
= false, 
  34                     bool shiftDown 
= false, 
  36                     bool metaDown 
= false); 
  39         Return the bit mask of all pressed modifier keys. 
  41         The return value is a combination of @c wxMOD_ALT, @c wxMOD_CONTROL, 
  42         @c wxMOD_SHIFT and @c wxMOD_META bit masks. Additionally, @c wxMOD_NONE 
  43         is defined as 0, i.e. corresponds to no modifiers (see HasModifiers()) 
  44         and @c wxMOD_CMD is either @c wxMOD_CONTROL (MSW and Unix) or @c 
  45         wxMOD_META (Mac), see CmdDown(). See @ref page_keymodifiers for the 
  46         full list of modifiers. 
  48         Notice that this function is easier to use correctly than, for example, 
  49         ControlDown() because when using the latter you also have to remember to 
  50         test that none of the other modifiers is pressed: 
  53         if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() ) 
  54             ... handle Ctrl-XXX ... 
  57         and forgetting to do it can result in serious program bugs (e.g. program 
  58         not working with European keyboard layout where @c AltGr key which is 
  59         seen by the program as combination of CTRL and ALT is used). On the 
  60         other hand, you can simply write: 
  63         if ( GetModifiers() == wxMOD_CONTROL ) 
  64             ... handle Ctrl-XXX ... 
  69     int GetModifiers() const; 
  72         Returns true if any modifiers at all are pressed. 
  74         This is equivalent to @c GetModifiers() @c != @c wxMOD_NONE. 
  76     bool HasModifiers() const; 
  79         Returns true if the Control key is pressed. 
  81         This function doesn't distinguish between right and left control keys. 
  83         In portable code you usually want to use CmdDown() to automatically 
  84         test for the more frequently used Command key (and not the rarely used 
  85         Control one) under Mac. 
  87         Notice that GetModifiers() should usually be used instead of this one. 
  89     bool ControlDown() const; 
  92         Returns true if the Shift key is pressed. 
  94         This function doesn't distinguish between right and left shift keys. 
  96         Notice that GetModifiers() should usually be used instead of this one. 
  98     bool ShiftDown() const; 
 101         Returns true if the Meta/Windows/Apple key is pressed. 
 103         This function tests the state of the key traditionally called Meta 
 104         under Unix systems, Windows keys under MSW and Apple, or Command, key 
 107         Notice that GetModifiers() should usually be used instead of this one. 
 111     bool MetaDown() const; 
 114         Returns true if the Alt key is pressed. 
 116         Notice that GetModifiers() should usually be used instead of this one. 
 118     bool AltDown() const; 
 121         Returns true if the key used for command accelerators is pressed. 
 123         @c Cmd is a pseudo key which is Control for PC and Unix platforms but 
 124         Apple (or Command) key under Macs: it makes often sense to use it 
 125         instead of ControlDown() because @c Command key is used for the same 
 126         thing under Mac as @c Control elsewhere (even though @c Control still 
 127         exists, it is usually not used for the same purpose under Mac). 
 129         Notice that GetModifiers() should usually be used instead of this one. 
 131     bool CmdDown() const;