Class: UnderOs::UI::Events::TouchListeners::Touch

Inherits:
Object
  • Object
show all
Defined in:
lib/under_os/ui/utils/events.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, position) ⇒ Touch

Returns a new instance of Touch.



85
86
87
88
# File 'lib/under_os/ui/utils/events.rb', line 85

def initialize(view, position)
  @view     = view
  @position = position
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



83
84
85
# File 'lib/under_os/ui/utils/events.rb', line 83

def position
  @position
end

#viewObject (readonly)

Returns the value of attribute view.



83
84
85
# File 'lib/under_os/ui/utils/events.rb', line 83

def view
  @view
end

Instance Method Details

#inspectObject



106
107
108
# File 'lib/under_os/ui/utils/events.rb', line 106

def inspect
  "#<Touch x=#{pageX} y=#{pageY}"
end

#pageXObject



90
91
92
# File 'lib/under_os/ui/utils/events.rb', line 90

def pageX
  position.x
end

#pageYObject



94
95
96
# File 'lib/under_os/ui/utils/events.rb', line 94

def pageY
  position.y
end

#viewXObject



98
99
100
# File 'lib/under_os/ui/utils/events.rb', line 98

def viewX
  @position.x - view._.frame.origin.x
end

#viewYObject



102
103
104
# File 'lib/under_os/ui/utils/events.rb', line 102

def viewY
  @position.y - view._.frame.origin.y
end