Class: Browser::Event::Mouse

Inherits:
UI show all
Defined in:
opal/browser/event/mouse.rb

Defined Under Namespace

Classes: Definition

Instance Attribute Summary

Attributes inherited from Browser::Event

#callback, #on

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Browser::Event

aliases, #arguments, #arguments=, class_for, create, handlers, handles, #initialize, #name, name_for, new, #off, #prevent, #prevented?, #stop, #stop!, #stopped?, #target

Constructor Details

This class inherits a constructor from Browser::Event

Class Method Details

.construct(name, desc) ⇒ Object



102
103
104
# File 'opal/browser/event/mouse.rb', line 102

def self.construct(name, desc)
  `new MouseEvent(#{name}, #{desc})`
end

.supported?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'opal/browser/event/mouse.rb', line 10

def self.supported?
  not $$[:MouseEvent].nil?
end

Instance Method Details

#ancestorObject



148
149
150
# File 'opal/browser/event/mouse.rb', line 148

def ancestor
  Position.new(`#@native.x`, `#@native.y`) unless `#@native.x == null`
end

#click?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'opal/browser/event/mouse.rb', line 172

def click?
  name.downcase == 'click'
end

#clientObject



128
129
130
# File 'opal/browser/event/mouse.rb', line 128

def client
  Position.new(`#@native.clientX`, `#@native.clientY`)
end

#double_click?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'opal/browser/event/mouse.rb', line 176

def double_click?
  name.downcase == 'dblclick'
end

#down?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'opal/browser/event/mouse.rb', line 180

def down?
  name.downcase == 'mousedown'
end

#enter?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'opal/browser/event/mouse.rb', line 184

def enter?
  name.downcase == 'mouseenter'
end

#fromObject



164
165
166
# File 'opal/browser/event/mouse.rb', line 164

def from
  DOM(`#@native.fromElement`) unless `#@native.fromElement == null`
end

#layerObject



132
133
134
# File 'opal/browser/event/mouse.rb', line 132

def layer
  Position.new(`#@native.layerX`, `#@native.layerY`) unless `#@native.layerX == null`
end

#leave?Boolean

Returns:

  • (Boolean)


188
189
190
# File 'opal/browser/event/mouse.rb', line 188

def leave?
  name.downcase == 'mouseleave'
end

#move?Boolean

Returns:

  • (Boolean)


192
193
194
# File 'opal/browser/event/mouse.rb', line 192

def move?
  name.downcase == 'mousemove'
end

#offsetObject



136
137
138
# File 'opal/browser/event/mouse.rb', line 136

def offset
  Position.new(`#@native.offsetX`, `#@native.offsetY`) unless `#@native.offsetX == null`
end

#out?Boolean

Returns:

  • (Boolean)


196
197
198
# File 'opal/browser/event/mouse.rb', line 196

def out?
  name.downcase == 'mouseout'
end

#over?Boolean

Returns:

  • (Boolean)


200
201
202
# File 'opal/browser/event/mouse.rb', line 200

def over?
  name.downcase == 'mouseover'
end

#pageObject



140
141
142
# File 'opal/browser/event/mouse.rb', line 140

def page
  Position.new(`#@native.pageX`, `#@native.pageY`) unless `#@native.pageX == null`
end


160
161
162
# File 'opal/browser/event/mouse.rb', line 160

def related
  DOM(`#@native.relatedTarget`) unless `#@native.relatedTarget == null`
end

#screenObject



144
145
146
# File 'opal/browser/event/mouse.rb', line 144

def screen
  Position.new(`#@native.screenX`, `#@native.screenY`) unless `#@native.screenX == null`
end

#show?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'opal/browser/event/mouse.rb', line 208

def show?
  name.downcase == 'show'
end

#toObject



168
169
170
# File 'opal/browser/event/mouse.rb', line 168

def to
  DOM(`#@native.toElement`) unless `#@native.toElement == null`
end

#up?Boolean

Returns:

  • (Boolean)


204
205
206
# File 'opal/browser/event/mouse.rb', line 204

def up?
  name.downcase == 'mouseup'
end

#xObject



152
153
154
# File 'opal/browser/event/mouse.rb', line 152

def x
  screen.x
end

#yObject



156
157
158
# File 'opal/browser/event/mouse.rb', line 156

def y
  screen.y
end