Class: Rubygame::EventTriggers::MouseReleaseTrigger

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygame/event_triggers.rb

Overview

MouseReleaseTrigger is an event trigger which fires when a mouse button is released (i.e. MouseReleased).

By default, this trigger fires for any mouse release, but it can be configured to fire for only a specific mouse button by passing a button symbol to #new.

See also MousePressTrigger.

Instance Method Summary collapse

Constructor Details

#initialize(button = :any) ⇒ MouseReleaseTrigger

Initialize a new instance of MouseReleaseTrigger with the given mouse button.

button

The mouse button symbol to detect, or :any to detect any button press.

Valid mouse button symbols are: :mouse_left, :mouse_middle, :mouse_right, :mouse_wheel_up, and :mouse_wheel_down.



654
655
656
# File 'lib/rubygame/event_triggers.rb', line 654

def initialize( button=:any )
	@button = button
end

Instance Method Details

#match?(event) ⇒ Boolean

Returns true if the event is a MouseReleased event and the event’s button is the same as the trigger’s button (or the trigger’s button is :any).

Returns:

  • (Boolean)


662
663
664
665
666
667
668
# File 'lib/rubygame/event_triggers.rb', line 662

def match?( event )
	if event.kind_of?( Rubygame::Events::MouseReleased )
		((@button == :any) or (event.button == @button))
	else
		false
	end
end