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, #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


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

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

.supported?Boolean

Returns:

  • (Boolean)

4
5
6
# File 'opal/browser/event/mouse.rb', line 4

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

Instance Method Details

#ancestorObject


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

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

#click?Boolean

Returns:

  • (Boolean)

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

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

#clientObject


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

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

#double_click?Boolean

Returns:

  • (Boolean)

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

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

#down?Boolean

Returns:

  • (Boolean)

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

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

#enter?Boolean

Returns:

  • (Boolean)

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

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

#fromObject


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

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

#layerObject


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

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

#leave?Boolean

Returns:

  • (Boolean)

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

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

#move?Boolean

Returns:

  • (Boolean)

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

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

#offsetObject


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

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

#out?Boolean

Returns:

  • (Boolean)

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

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

#over?Boolean

Returns:

  • (Boolean)

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

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

#pageObject


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

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

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

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

#screenObject


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

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

#show?Boolean

Returns:

  • (Boolean)

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

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

#toObject


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

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

#up?Boolean

Returns:

  • (Boolean)

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

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

#xObject


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

def x
  screen.x
end

#yObject


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

def y
  screen.y
end