# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # Provides methods for testing the state of the keyboard modifier keys. # This class is used as a base class of {Wx::KeyEvent} and {Wx::MouseState} and, hence, indirectly, of {Wx::MouseEvent}, so its methods may be used to get information about the modifier keys which were pressed when the event occurred. # This class is implemented entirely inline in <{Wx::/kbdstate.h}> and thus has no linking requirements. # === # # Category: {Wx::Events} # @see Wx::KeyEvent # @see Wx::MouseState # # class KeyboardState < ::Object # Constructor initializes the modifier key settings. # By default, no modifiers are active. # @param controlDown [true,false] # @param shiftDown [true,false] # @param altDown [true,false] # @param metaDown [true,false] # @return [KeyboardState] def initialize(controlDown=false, shiftDown=false, altDown=false, metaDown=false) end # Return the bit mask of all pressed modifier keys. # The return value is a combination of {Wx::KeyModifier::MOD_ALT}, {Wx::KeyModifier::MOD_CONTROL}, {Wx::KeyModifier::MOD_SHIFT} and {Wx::KeyModifier::MOD_META} bit masks. Additionally, {Wx::KeyModifier::MOD_NONE} is defined as 0, i.e. corresponds to no modifiers (see {Wx::KeyboardState#has_any_modifiers}) and {Wx::KeyModifier::MOD_CMD} is either {Wx::KeyModifier::MOD_CONTROL} (MSW and Unix) or {Wx::KeyModifier::MOD_META} (Mac), see {Wx::KeyboardState#cmd_down}. See {Wx::KeyModifier} for the full list of modifiers. # Notice that this function is easier to use correctly than, for example, {Wx::KeyboardState#control_down} because when using the latter you also have to remember to test that none of the other modifiers is pressed: # # if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() ) # ... handle Ctrl-XXX ... # # and forgetting to do it can result in serious program bugs (e.g. program not working with European keyboard layout where AltGr key which is seen by the program as combination of CTRL and ALT is used). On the other hand, you can simply write: # # if ( GetModifiers() == wxMOD_CONTROL ) # ... handle Ctrl-XXX ... # # with this function. # @return [Integer] def get_modifiers; end alias_method :modifiers, :get_modifiers # Returns true if any modifiers at all are pressed. # This is equivalent to Wx::KeyboardState#get_modifiers != {Wx::KeyModifier::MOD_NONE}. # Notice that this is different from {Wx::KeyboardState#has_modifiers} 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. # @return [true,false] def has_any_modifiers; end alias_method :has_any_modifiers?, :has_any_modifiers # Returns true if Control or Alt are pressed. # Checks if Control, Alt or, under macOS 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 {Wx::KeyboardState#has_any_modifiers} if you want to take Shift into account as well. # @return [true,false] def has_modifiers; end alias_method :has_modifiers?, :has_modifiers # Returns true if the Control key or Apple/Command key under macOS is pressed. # This function doesn't distinguish between right and left control keys. # Notice that {Wx::KeyboardState#get_modifiers} should usually be used instead of this one. # @return [true,false] def control_down; end # Returns true if the Control key (also under macOS). # This function doesn't distinguish between right and left control keys. # Notice that {Wx::KeyboardState#get_modifiers} should usually be used instead of this one. # @return [true,false] def raw_control_down; end # Returns true if the Shift key is pressed. # This function doesn't distinguish between right and left shift keys. # Notice that {Wx::KeyboardState#get_modifiers} should usually be used instead of this one. # @return [true,false] def shift_down; end # Returns true if the Meta/Windows/Apple key is pressed. # This function tests the state of the key traditionally called Meta under Unix systems, Windows keys under MSW Notice that {Wx::KeyboardState#get_modifiers} should usually be used instead of this one. # @see Wx::KeyboardState#cmd_down # @return [true,false] def meta_down; end # Returns true if the Alt key is pressed. # Notice that {Wx::KeyboardState#get_modifiers} should usually be used instead of this one. # @return [true,false] def alt_down; end # Returns true if the key used for command accelerators is pressed. # Same as {Wx::KeyboardState#control_down}. Deprecated. # Notice that {Wx::KeyboardState#get_modifiers} should usually be used instead of this one. # @return [true,false] def cmd_down; end # @param down [true,false] # @return [void] def set_control_down(down) end alias_method :control_down=, :set_control_down # @param down [true,false] # @return [void] def set_raw_control_down(down) end alias_method :raw_control_down=, :set_raw_control_down # @param down [true,false] # @return [void] def set_shift_down(down) end alias_method :shift_down=, :set_shift_down # @param down [true,false] # @return [void] def set_alt_down(down) end alias_method :alt_down=, :set_alt_down # @param down [true,false] # @return [void] def set_meta_down(down) end alias_method :meta_down=, :set_meta_down end # KeyboardState end