class UnderOs::UI::Events::TouchListeners
Public Class Methods
add(eventname, view)
click to toggle source
# File lib/under_os/ui/utils/events.rb, line 40 def self.add(eventname, view) listeners[eventname] << view end
listeners()
click to toggle source
# File lib/under_os/ui/utils/events.rb, line 36 def self.listeners @listeners ||= Hash.new{ |h,k| h[k] = [] } end
notify(eventname, event)
click to toggle source
# File lib/under_os/ui/utils/events.rb, line 44 def self.notify(eventname, event) listeners[eventname].each do |view| if eventname == :touchmove # being nice and throttling the touchmove events return if @__working @__working = true end touches = touches_for_view(view, event) view.emit(eventname, touches: touches) if touches.size > 0 @__working = false end end
touch_inside_of(frame, touch)
click to toggle source
# File lib/under_os/ui/utils/events.rb, line 72 def self.touch_inside_of(frame, touch) point = touch.locationInView(nil) point = nil if point.x < frame.origin.x || point.y < frame.origin.y || point.x > frame.origin.x + frame.size.width || point.y > frame.origin.y + frame.size.height point end
touches_for_view(view, event)
click to toggle source
# File lib/under_os/ui/utils/events.rb, line 59 def self.touches_for_view(view, event) frame = view._.frame touches = [] event.allTouches.each do |touch| if point = touch_inside_of(frame, touch) touches << Touch.new(view, point) end end touches end