Class: Moon::InputEvent

Inherits:
Event show all
Defined in:
lib/moon/packages/std/event.rb

Overview

Base class for Input related events.

Direct Known Subclasses

KeyboardInputEvent, MouseInputEvent

Instance Attribute Summary collapse

Attributes inherited from Event

#id, #type

Instance Method Summary collapse

Methods inherited from Event

make_filter

Constructor Details

#initialize(key, action, mods) ⇒ InputEvent

Returns a new instance of InputEvent.

Parameters:


57
58
59
60
61
62
# File 'lib/moon/packages/std/event.rb', line 57

def initialize(key, action, mods)
  super action
  @type = @action = action
  @key = key
  @mods = mods
end

Instance Attribute Details

#actionSymbol

Returns state of the key, whether its :press, :release, or :repeat.

Returns:

  • (Symbol)

    state of the key, whether its :press, :release, or :repeat


43
44
45
# File 'lib/moon/packages/std/event.rb', line 43

def action
  @action
end

#keySymbol Also known as: button

Returns name of the key.

Returns:

  • (Symbol)

    name of the key


46
47
48
# File 'lib/moon/packages/std/event.rb', line 46

def key
  @key
end

#modsInteger

Returns modifiers.

Returns:


49
50
51
# File 'lib/moon/packages/std/event.rb', line 49

def mods
  @mods
end

Instance Method Details

#alt?Boolean

Is the alt modifier active?

Returns:


65
66
67
# File 'lib/moon/packages/std/event.rb', line 65

def alt?
  @mods.masked? Moon::Input::MOD_ALT
end

#control?Boolean

Is the control modifier active?

Returns:


70
71
72
# File 'lib/moon/packages/std/event.rb', line 70

def control?
  @mods.masked? Moon::Input::MOD_CONTROL
end

#shift?Boolean

Is the shift modifier active?

Returns:


80
81
82
# File 'lib/moon/packages/std/event.rb', line 80

def shift?
  @mods.masked? Moon::Input::MOD_SHIFT
end

#super?Boolean

Is the super/winkey modifier active?

Returns:


75
76
77
# File 'lib/moon/packages/std/event.rb', line 75

def super?
  @mods.masked? Moon::Input::MOD_SUPER
end