Module Rubygame::Events
In: lib/rubygame/events.rb

The Events module contains classes representing various hardware events (e.g. keyboard presses, mouse clicks) and software events (e.g. clock tick, window becomes active)

This event classes are meant as a full replacement for the older event classes defined in the Rubygame module (e.g. KeyDownEvent, QuitEvent). The old classes are deprecated and should not be used anymore.


Classes and Modules

Module Rubygame::Events::JoystickButtonEvent
Module Rubygame::Events::KeyboardEvent
Module Rubygame::Events::MouseButtonEvent
Class Rubygame::Events::ClockTicked
Class Rubygame::Events::InputFocusGained
Class Rubygame::Events::InputFocusLost
Class Rubygame::Events::JoystickAxisMoved
Class Rubygame::Events::JoystickBallMoved
Class Rubygame::Events::JoystickButtonPressed
Class Rubygame::Events::JoystickButtonReleased
Class Rubygame::Events::JoystickHatMoved
Class Rubygame::Events::KeyPressed
Class Rubygame::Events::KeyReleased
Class Rubygame::Events::MouseFocusGained
Class Rubygame::Events::MouseFocusLost
Class Rubygame::Events::MouseMoved
Class Rubygame::Events::MousePressed
Class Rubygame::Events::MouseReleased
Class Rubygame::Events::QuitRequested
Class Rubygame::Events::WindowExposed
Class Rubygame::Events::WindowMinimized
Class Rubygame::Events::WindowResized
Class Rubygame::Events::WindowUnminimized

Public Class methods

NOTE: This method converts the SDL events into the new-style event classes, located in the Rubygame::Events module. For converting to the older (deprecated) events, see Rubygame.fetch_sdl_events.

Retrieves all pending events from SDL’s event stack and converts them into Rubygame event objects. Returns an Array of all the events, in the order they were read.

This method is used by the EventQueue class (among others), so don’t call it if you are using any of Rubygame’s event management classes (e.g. EventQueue)! If you do, they will not receive all the events, because some events will have been removed from SDL’s event stack by this method.

However, if you aren’t using EventQueue, you can safely use this method to make your own event management system.


# File lib/rubygame/events.rb, line 117
    def self.fetch_sdl_events
      events = []
      until( ( event = SDL::PollEvent() ).nil? )
        case ( event = _convert_sdlevent(event) )
        when Array;   events += event
        else;         events << event
      return events