Module: Tea::Event
- Defined in:
- lib/tea/m_event.rb,
lib/tea/m_event_app.rb,
lib/tea/m_event_mouse.rb,
lib/tea/m_event_dispatch.rb,
lib/tea/m_event_keyboard.rb
Overview
The Event module allows access to the event queue, and the classes of events that come out.
Defined Under Namespace
Modules: Dispatch
Constant Summary collapse
- APPMOUSEFOCUS_ =
APP constants rubysdl is missing. For internal use only.
0x01
- APPINPUTFOCUS_ =
0x02
- APPACTIVE_ =
0x04
- BUTTON_WHEELUP_ =
Missing mouse wheel button constants from rubysdl. For internal use only.
4
- BUTTON_WHEELDOWN_ =
5
- @@event_queue =
Tea’s generated event queue. Add to the back, get from the front.
[]
Class Method Summary collapse
-
.get(wait = false) ⇒ Object
Get the next event in the event queue.
Class Method Details
.get(wait = false) ⇒ Object
Get the next event in the event queue. If wait is true and there are no events to return, this method will wait until there is one and return it. Otherwise, an empty event queue will return nil.
May raise Tea::Error if getting an event fails.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tea/m_event.rb', line 26 def Event.get(wait=false) if @@event_queue.length == 0 if wait begin sdl_event = SDL::Event.wait if (out_events = translate_event(sdl_event)) @@event_queue.push *out_events end end until @@event_queue.length > 0 else if (out_events = translate_event(SDL::Event.poll)) @@event_queue.push *out_events end end end tea_event = @@event_queue.shift [App, Mouse, Kbd].each { |state_holder| state_holder.update_state tea_event } tea_event rescue SDL::Error => e raise Tea::Error, e., e.backtrace end |