Class: Dommy::MouseEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/dommy/event.rb

Direct Known Subclasses

DragEvent, PointerEvent, WheelEvent

Constant Summary

Constants inherited from Event

Event::JS_METHOD_NAMES

Instance Attribute Summary

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__internal_prepare_for_dispatch__, #__internal_record_path__, #__internal_set_current_target__, #__js_call__, #__js_method_names__, #__js_set__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Constructor Details

#initialize(type, init = nil) ⇒ MouseEvent

Returns a new instance of MouseEvent.



384
385
386
387
388
389
390
391
392
393
# File 'lib/dommy/event.rb', line 384

def initialize(type, init = nil)
  super
  @button = read_init(init, "button") || 0
  @ctrl_key = !!read_init(init, "ctrlKey")
  @shift_key = !!read_init(init, "shiftKey")
  @alt_key = !!read_init(init, "altKey")
  @meta_key = !!read_init(init, "metaKey")
  @client_x = read_init(init, "clientX") || 0
  @client_y = read_init(init, "clientY") || 0
end

Instance Method Details

#__js_get__(key) ⇒ Object



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/dommy/event.rb', line 395

def __js_get__(key)
  case key
  when "button"
    @button
  when "ctrlKey"
    @ctrl_key
  when "shiftKey"
    @shift_key
  when "altKey"
    @alt_key
  when "metaKey"
    @meta_key
  when "clientX"
    @client_x
  when "clientY"
    @client_y
  else
    super
  end
end