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


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

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

.supported?Boolean

Returns:

  • (Boolean)

8
9
10
# File 'opal/browser/event/mouse.rb', line 8

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

Instance Method Details

#ancestorObject


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

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

#click?Boolean

Returns:

  • (Boolean)

217
218
219
# File 'opal/browser/event/mouse.rb', line 217

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

#clientObject


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

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

#double_click?Boolean

Returns:

  • (Boolean)

221
222
223
# File 'opal/browser/event/mouse.rb', line 221

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

#down?Boolean

Returns:

  • (Boolean)

225
226
227
# File 'opal/browser/event/mouse.rb', line 225

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

#enter?Boolean

Returns:

  • (Boolean)

229
230
231
# File 'opal/browser/event/mouse.rb', line 229

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

#fromObject


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

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

#layerObject


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

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

#leave?Boolean

Returns:

  • (Boolean)

233
234
235
# File 'opal/browser/event/mouse.rb', line 233

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

#move?Boolean

Returns:

  • (Boolean)

237
238
239
# File 'opal/browser/event/mouse.rb', line 237

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

#offsetObject


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

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

#out?Boolean

Returns:

  • (Boolean)

241
242
243
# File 'opal/browser/event/mouse.rb', line 241

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

#over?Boolean

Returns:

  • (Boolean)

245
246
247
# File 'opal/browser/event/mouse.rb', line 245

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

#pageObject


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

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

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

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

#screenObject


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

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

#show?Boolean

Returns:

  • (Boolean)

253
254
255
# File 'opal/browser/event/mouse.rb', line 253

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

#toObject


213
214
215
# File 'opal/browser/event/mouse.rb', line 213

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

#up?Boolean

Returns:

  • (Boolean)

249
250
251
# File 'opal/browser/event/mouse.rb', line 249

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

#xObject


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

def x
  screen.x
end

#yObject


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

def y
  screen.y
end