Class: Event

Inherits:
Object
  • Object
show all
Defined in:
opal/opal-jquery/event.rb

Overview

Wraps native jQuery event objects.

Instance Method Summary (collapse)

Constructor Details

- (Event) initialize(native)

Returns a new instance of Event



7
8
9
# File 'opal/opal-jquery/event.rb', line 7

def initialize(native)
  @native = native
end

Instance Method Details

- (Object) [](name)



11
12
13
# File 'opal/opal-jquery/event.rb', line 11

def [](name)
  `#@native[name]`
end

- (Object) ctrl_key



85
86
87
# File 'opal/opal-jquery/event.rb', line 85

def ctrl_key
  `#@native.ctrlKey`
end

- (Object) current_target

Element



22
23
24
# File 'opal/opal-jquery/event.rb', line 22

def current_target
  `$(#@native.currentTarget)`
end

- (Object) key_code



89
90
91
# File 'opal/opal-jquery/event.rb', line 89

def key_code
  `#@native.keyCode`
end

- (Object) kill

Stops propagation and prevents default action.



54
55
56
57
# File 'opal/opal-jquery/event.rb', line 54

def kill
  stop
  prevent
end

- (Object) page_x

Keyboard/Mouse/Touch



69
70
71
# File 'opal/opal-jquery/event.rb', line 69

def page_x
  `#@native.pageX`
end

- (Object) page_y



73
74
75
# File 'opal/opal-jquery/event.rb', line 73

def page_y
  `#@native.pageY`
end

- (Object) prevent Also known as: prevent_default



37
38
39
# File 'opal/opal-jquery/event.rb', line 37

def prevent
  `#@native.preventDefault()`
end

- (Boolean) prevented? Also known as: default_prevented?

Propagation

Returns:

  • (Boolean)


33
34
35
# File 'opal/opal-jquery/event.rb', line 33

def prevented?
  `#@native.isDefaultPrevented()`
end

- (Object) stop Also known as: stop_propagation



45
46
47
# File 'opal/opal-jquery/event.rb', line 45

def stop
  `#@native.stopPropagation()`
end

- (Object) stop_immediate Also known as: stop_immediate_propagation



49
50
51
# File 'opal/opal-jquery/event.rb', line 49

def stop_immediate
  `#@native.stopImmediatePropagation()`
end

- (Boolean) stopped? Also known as: propagation_stopped?

Returns:

  • (Boolean)


41
42
43
# File 'opal/opal-jquery/event.rb', line 41

def stopped?
  `#@native.isPropagationStopped()`
end

- (Object) target



26
27
28
# File 'opal/opal-jquery/event.rb', line 26

def target
  `$(#@native.target)`
end

- (Object) touch_x



77
78
79
# File 'opal/opal-jquery/event.rb', line 77

def touch_x
  `#@native.originalEvent.touches[0].pageX`
end

- (Object) touch_y



81
82
83
# File 'opal/opal-jquery/event.rb', line 81

def touch_y
  `#@native.originalEvent.touches[0].pageY`
end

- (Object) type



15
16
17
# File 'opal/opal-jquery/event.rb', line 15

def type
  `#@native.type`
end

- (Object) which



93
94
95
# File 'opal/opal-jquery/event.rb', line 93

def which
  `#@native.which`
end