Class: Rubygame::EventTriggers::KeyReleaseTrigger
- Inherits:
-
Object
- Object
- Rubygame::EventTriggers::KeyReleaseTrigger
- Defined in:
- lib/rubygame/event_triggers.rb
Overview
KeyReleaseTrigger is an event trigger which fires when a key on the keyboard is released (i.e. KeyReleased).
NOTE: This trigger is identical to KeyPressTrigger, except that it fires for KeyReleased instead of KeyPressed. Please see the documentation for KeyPressTrigger for info about the parameters and behavior of the trigger.
NOTE: This trigger only works with the new-style KeyReleased event class, not with the older KeyUpEvent. See EventQueue#enable_new_style_events
Instance Method Summary collapse
-
#initialize(key = :any, mods = :any) ⇒ KeyReleaseTrigger
constructor
Initialize a new instance of KeyReleaseTrigger with the given key and modifier keys.
-
#match?(event) ⇒ Boolean
Returns true if the event is a KeyReleased event and the event’s key and mods BOTH match the trigger’s expectations.
Constructor Details
#initialize(key = :any, mods = :any) ⇒ KeyReleaseTrigger
Initialize a new instance of KeyReleaseTrigger with the given key and modifier keys.
See KeyPressTrigger#new for more information and examples.
430 431 432 433 |
# File 'lib/rubygame/event_triggers.rb', line 430 def initialize( key=:any, mods=:any ) @key = key @mods = mods end |
Instance Method Details
#match?(event) ⇒ Boolean
Returns true if the event is a KeyReleased event and the event’s key and mods BOTH match the trigger’s expectations.
See KeyPressTrigger#match? for more information.
440 441 442 443 444 445 446 |
# File 'lib/rubygame/event_triggers.rb', line 440 def match?( event ) if event.kind_of?( Rubygame::Events::KeyReleased ) ((@key == :any) or (event.key == @key)) and \ ((@mods == :any) or (@mods == :none and event.modifiers == [])\ or (_mods_match?(event.modifiers))) end end |