Class: Dommy::InputEvent

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

Overview

‘InputEvent` — fired by `input` / `beforeinput`. Carries `data` (the inserted text, if any) and `inputType` (insertText, deleteContentBackward, etc.).

Instance Attribute Summary

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__js_call__, #__js_set__, #__prepare_for_dispatch__, #__record_path__, #__set_current_target__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Constructor Details

#initialize(type, init = nil) ⇒ InputEvent

Returns a new instance of InputEvent.



452
453
454
455
456
457
# File 'lib/dommy/event.rb', line 452

def initialize(type, init = nil)
  super
  @data = read_init(init, "data")
  @input_type = (read_init(init, "inputType") || "").to_s
  @is_composing = !!read_init(init, "isComposing")
end

Instance Method Details

#__js_get__(key) ⇒ Object



459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/dommy/event.rb', line 459

def __js_get__(key)
  case key
  when "data"
    @data
  when "inputType"
    @input_type
  when "isComposing"
    @is_composing
  else
    super
  end
end