Class: Wx::KeyboardState

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/keyboard_state.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

Provides methods for testing the state of the keyboard modifier keys.

This class is used as a base class of KeyEvent and MouseState and, hence, indirectly, of 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 </kbdstate.h> and thus has no linking requirements.

Category: Events

See Also:

Direct Known Subclasses

MouseState

Instance Method Summary collapse

Constructor Details

#initialize(controlDown = false, shiftDown = false, altDown = false, metaDown = false) ⇒ Wx::KeyboardState

Constructor initializes the modifier key settings.

By default, no modifiers are active.

Parameters:

  • controlDown (Boolean) (defaults to: false)
  • shiftDown (Boolean) (defaults to: false)
  • altDown (Boolean) (defaults to: false)
  • metaDown (Boolean) (defaults to: false)


31
# File 'lib/wx/doc/gen/keyboard_state.rb', line 31

def initialize(controlDown=false, shiftDown=false, altDown=false, metaDown=false) end

Instance Method Details

#alt_downBoolean

Returns true if the Alt key is pressed.

Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


103
# File 'lib/wx/doc/gen/keyboard_state.rb', line 103

def alt_down; end

#cmd_downBoolean

Returns true if the key used for command accelerators is pressed.

Same as #control_down. Deprecated. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


110
# File 'lib/wx/doc/gen/keyboard_state.rb', line 110

def cmd_down; end

#control_downBoolean

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 #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


76
# File 'lib/wx/doc/gen/keyboard_state.rb', line 76

def control_down; end

#get_modifiersInteger Also known as: modifiers

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 #has_any_modifiers) and Wx::KeyModifier::MOD_CMD is either Wx::KeyModifier::MOD_CONTROL (MSW and Unix) or Wx::KeyModifier::MOD_META (Mac), see #cmd_down. See Wx::KeyModifier for the full list of modifiers. Notice that this function is easier to use correctly than, for example, #control_down because when using the latter you also have to remember to test that none of the other modifiers is pressed:

if control_down && !alt_down && !shift_down && !meta_down
    ... 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 get_modifiers == Wx::MOD_CONTROL
    ... handle Ctrl-XXX ...

with this function.

Returns:

  • (Integer)


52
# File 'lib/wx/doc/gen/keyboard_state.rb', line 52

def get_modifiers; end

#has_any_modifiersBoolean Also known as: has_any_modifiers?

Returns true if any modifiers at all are pressed.

This is equivalent to get_modifiers != Wx::KeyModifier::MOD_NONE. Notice that this is different from #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.

Returns:

  • (Boolean)


60
# File 'lib/wx/doc/gen/keyboard_state.rb', line 60

def has_any_modifiers; end

#has_modifiersBoolean Also known as: has_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 #has_any_modifiers if you want to take Shift into account as well.

Returns:

  • (Boolean)


68
# File 'lib/wx/doc/gen/keyboard_state.rb', line 68

def has_modifiers; end

#meta_downBoolean

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 #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)

See Also:



97
# File 'lib/wx/doc/gen/keyboard_state.rb', line 97

def meta_down; end

#raw_control_downBoolean

Returns true if the Control key (also under macOS).

This function doesn’t distinguish between right and left control keys. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


83
# File 'lib/wx/doc/gen/keyboard_state.rb', line 83

def raw_control_down; end

#set_alt_down(down) ⇒ void Also known as: alt_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


129
# File 'lib/wx/doc/gen/keyboard_state.rb', line 129

def set_alt_down(down) end

#set_control_down(down) ⇒ void Also known as: control_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


114
# File 'lib/wx/doc/gen/keyboard_state.rb', line 114

def set_control_down(down) end

#set_meta_down(down) ⇒ void Also known as: meta_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


134
# File 'lib/wx/doc/gen/keyboard_state.rb', line 134

def set_meta_down(down) end

#set_raw_control_down(down) ⇒ void Also known as: raw_control_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


119
# File 'lib/wx/doc/gen/keyboard_state.rb', line 119

def set_raw_control_down(down) end

#set_shift_down(down) ⇒ void Also known as: shift_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


124
# File 'lib/wx/doc/gen/keyboard_state.rb', line 124

def set_shift_down(down) end

#shift_downBoolean

Returns true if the Shift key is pressed.

This function doesn’t distinguish between right and left shift keys. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


90
# File 'lib/wx/doc/gen/keyboard_state.rb', line 90

def shift_down; end