Class: Dommy::MouseEvent

Inherits:
UIEvent show all
Defined in:
lib/dommy/event.rb

Direct Known Subclasses

DragEvent, PointerEvent, WheelEvent

Constant Summary

Constants inherited from Event

Event::AT_TARGET, Event::BUBBLING_PHASE, Event::CAPTURING_PHASE, Event::NONE

Instance Attribute Summary

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__internal_clear_propagation_flags__, #__internal_mark_trusted__, #__internal_prepare_for_dispatch__, #__internal_record_path__, #__internal_run_passive__, #__internal_set_current_target__, #__internal_set_dispatch_flag__, #__internal_set_event_phase__, #__js_set__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Methods included from Bridge::Methods

included

Constructor Details

#initialize(type, init = nil) ⇒ MouseEvent

Returns a new instance of MouseEvent.



816
817
818
819
820
821
822
823
824
825
826
827
828
829
# File 'lib/dommy/event.rb', line 816

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")
  @buttons = read_init(init, "buttons") || 0
  @related_target = read_init(init, "relatedTarget")
  @screen_x = read_init(init, "screenX") || 0
  @screen_y = read_init(init, "screenY") || 0
  @client_x = read_init(init, "clientX") || 0
  @client_y = read_init(init, "clientY") || 0
end

Instance Method Details

#__js_call__(method, args) ⇒ Object



861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/dommy/event.rb', line 861

def __js_call__(method, args)
  case method
  when "initMouseEvent"
    # Legacy initMouseEvent(type, bubbles, cancelable, view, detail, screenX,
    # screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button,
    # relatedTarget). A no-op while dispatching.
    raise Bridge::TypeError, "initMouseEvent requires a type argument" if args.empty?

    unless @dispatch_flag
      init_event(args[0], args[1], args[2])
      @view = args[3]
      @detail = (args[4] || 0).to_i
      @screen_x = (args[5] || 0).to_i
      @screen_y = (args[6] || 0).to_i
      @client_x = (args[7] || 0).to_i
      @client_y = (args[8] || 0).to_i
      @ctrl_key = !!args[9]
      @alt_key = !!args[10]
      @shift_key = !!args[11]
      @meta_key = !!args[12]
      @button = (args[13] || 0).to_i
    end
    nil
  else
    super
  end
end

#__js_get__(key) ⇒ Object



831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
# File 'lib/dommy/event.rb', line 831

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 "buttons"
    @buttons
  when "relatedTarget"
    @related_target
  when "screenX"
    @screen_x
  when "screenY"
    @screen_y
  when "clientX"
    @client_x
  when "clientY"
    @client_y
  else
    super
  end
end