### Home Classes Methods

### In Files

- lib/rubygame/event_triggers.rb

### Parent

Object

### Methods

- ::new
- #match?

### Files

- CREDITS
- LICENSE
- NEWS
- README
- ROADMAP
- custom_sdl_load_paths.rdoc
- getting_started.rdoc
- keyboard_symbols.rdoc
- macosx_install.rdoc
- managing_framerate.rdoc
- surface_palettes.rdoc
- windows_install.rdoc

### Class/Module Index

Quicksearch

- Rubygame
- Rubygame::ActiveEvent
- Rubygame::Clock
- Rubygame::Color
- Rubygame::Color::ColorBase
- Rubygame::Color::ColorHSL
- Rubygame::Color::ColorHSV
- Rubygame::Color::ColorRGB
- Rubygame::Color::Palette
- Rubygame::Event
- Rubygame::EventActions
- Rubygame::EventActions::BlockAction
- Rubygame::EventActions::MethodAction
- Rubygame::EventActions::MultiAction
- Rubygame::EventHandler
- Rubygame::EventHandler::HasEventHandler
- Rubygame::EventHook
- Rubygame::EventQueue
- Rubygame::EventTriggers
- Rubygame::EventTriggers::AndTrigger
- Rubygame::EventTriggers::AttrTrigger
- Rubygame::EventTriggers::BlockTrigger
- Rubygame::EventTriggers::InstanceOfTrigger
- Rubygame::EventTriggers::KeyPressTrigger
- Rubygame::EventTriggers::KeyReleaseTrigger
- Rubygame::EventTriggers::KindOfTrigger
- Rubygame::EventTriggers::MouseMoveTrigger
- Rubygame::EventTriggers::MousePressTrigger
- Rubygame::EventTriggers::MouseReleaseTrigger
- Rubygame::EventTriggers::OrTrigger
- Rubygame::EventTriggers::TickTrigger
- Rubygame::EventTriggers::YesTrigger
- Rubygame::Events
- Rubygame::Events::ClockTicked
- Rubygame::Events::InputFocusGained
- Rubygame::Events::InputFocusLost
- Rubygame::Events::JoystickAxisMoved
- Rubygame::Events::JoystickBallMoved
- Rubygame::Events::JoystickButtonEvent
- Rubygame::Events::JoystickButtonPressed
- Rubygame::Events::JoystickButtonReleased
- Rubygame::Events::JoystickHatMoved
- Rubygame::Events::KeyPressed
- Rubygame::Events::KeyReleased
- Rubygame::Events::KeyboardEvent
- Rubygame::Events::MouseButtonEvent
- Rubygame::Events::MouseFocusGained
- Rubygame::Events::MouseFocusLost
- Rubygame::Events::MouseMoved
- Rubygame::Events::MousePressed
- Rubygame::Events::MouseReleased
- Rubygame::Events::QuitRequested
- Rubygame::Events::WindowExposed
- Rubygame::Events::WindowMinimized
- Rubygame::Events::WindowResized
- Rubygame::Events::WindowUnminimized
- Rubygame::ExposeEvent
- Rubygame::Ftor
- Rubygame::GL
- Rubygame::Hotspot
- Rubygame::JoyAxisEvent
- Rubygame::JoyBallEvent
- Rubygame::JoyDownEvent
- Rubygame::JoyHatEvent
- Rubygame::JoyUpEvent
- Rubygame::Joystick
- Rubygame::Key
- Rubygame::KeyDownEvent
- Rubygame::KeyUpEvent
- Rubygame::MailQueue
- Rubygame::MediaBag
- Rubygame::Mixer
- Rubygame::Mixer::Music
- Rubygame::Mixer::Sample
- Rubygame::Mouse
- Rubygame::MouseDownEvent
- Rubygame::MouseMotionEvent
- Rubygame::MouseUpEvent
- Rubygame::Music
- Rubygame::NamedResource
- Rubygame::NamedResource::NamedResourceClassMethods
- Rubygame::QuitEvent
- Rubygame::Rect
- Rubygame::ResizeEvent
- Rubygame::SDLError
- Rubygame::SFont
- Rubygame::Screen
- Rubygame::Sound
- Rubygame::Sprites
- Rubygame::Sprites::DepthSortGroup
- Rubygame::Sprites::Group
- Rubygame::Sprites::LimitGroup
- Rubygame::Sprites::Sprite
- Rubygame::Sprites::UpdateGroup
- Rubygame::Surface
- Rubygame::TTF

No matching classes.

# Rubygame::EventTriggers::MouseMoveTrigger

MouseMoveTrigger is an event trigger which fires when the mouse cursor is moved (MouseMoved). If buttons are given, it only matches events with those buttons. See new for details.

### Public Class Methods

new( buttons=:any ) click to toggle source

Create a new instance of MouseMoveTrigger.

The buttons parameter determines which mouse buttons can be held down and still match this trigger. It can be one of:

1. `:any`. Matches if zero or more buttons are held.

2. `:none`. Matches when zero buttons are being held.

3. `:mouse_left`, etc. Matches when at least the given button is being held.

4. An array of `:mouse_*` symbols. Matches when exactly all buttons in the Array are being held, and nothing else.

Example:

    # Matches all MouseMoved events, regardless of buttons:
    MouseMoveTrigger.new()
    MouseMoveTrigger.new( :any )

    # Matches only if no buttons pressed:
    MouseMoveTrigger.new( :none )
    MouseMoveTrigger.new( [] )

    # Matches if left mouse is held down, maybe with others:
    MouseMoveTrigger.new( :mouse_left )

    # Matches if ONLY left mouse held down, nothing else:
    MouseMoveTrigger.new( [:mouse_left] )

    # Matches if BOTH left AND right mouse are held down, nothing else:
    MouseMoveTrigger.new( [:mouse_left, :mouse_right] )

    # Matches if EITHER left OR right mouse are held down:
    OrTrigger.new( MouseMoveTrigger.new(:mouse_left),
                   MouseMoveTrigger.new(:mouse_right) )

    # File lib/rubygame/event_triggers.rb, line 594
    def initialize( buttons=:any )
            @buttons = buttons
    end

### Public Instance Methods

match?( event ) click to toggle source

Returns true if the given event matches this trigger. See new for information about how events match.

    # File lib/rubygame/event_triggers.rb, line 602
    def match?( event )
            if event.kind_of?( Rubygame::Events::MouseMoved )
                    ((@buttons == :any) or
                     (@buttons == :none and event.buttons == []) or
                     (_buttons_match?(event.buttons)) or
                     (event.buttons.include?(@buttons)))
            else
                    false
            end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.