Sha256: 87d6ada9710ab8a13a87e7caa49866e9ab5c5315de104c3a2b681684adb79142
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module Ray module DSL # Module charged to translate an instance of Ray::Event into the arguments # you pass to raise_event. module EventTranslator FOCUS_TYPE = { Ray::Event::APPMOUSEFOCUS => :mouse_focus, Ray::Event::APPINPUTFOCUS => :input_focus, Ray::Event::APPACTIVE => :app_activity } class << self # @return [Array, nil] The arguments you should pass to raise_event. def translate_event(ev) case ev.type when 0 then nil when Ray::Event::TYPE_QUIT then quit(ev) when Ray::Event::TYPE_ACTIVEEVENT then active_event(ev) when Ray::Event::TYPE_MOUSEMOTION then mouse_motion(ev) else nil end end def quit(ev) [:quit] end def active_event(ev) [ev.is_gain? ? :focus_gain : :focus_loss, FOCUS_TYPE[ev.focus_state]] end def mouse_motion(ev) [:mouse_motion, Ray::Rect.new(ev.mouse_x, ev.mouse_y)] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ray-0.0.0.pre2 | lib/ray/dsl/event_translator.rb |