Class: GlimR::Event
Overview
Implements the <a href=“www.w3.org/TR/DOM-Level-2-Events”>W3C DOM Event model</a> event interface.
Much like the ECMAScript API.
Instance Attribute Summary collapse
-
#cancelled ⇒ Object
readonly
Returns the value of attribute cancelled.
-
#params ⇒ Object
Returns the value of attribute params.
-
#phase ⇒ Object
Returns the value of attribute phase.
-
#stopped ⇒ Object
readonly
Returns the value of attribute stopped.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, params = {:bubbles => true, :cancelable => false}) ⇒ Event
constructor
Creates a new event of the given type, sets params to param hash.
-
#prevent_default ⇒ Object
Cancels the event’s possible default behaviour.
-
#stop_propagation ⇒ Object
Stops the handling of the event.
Constructor Details
#initialize(type, params = {:bubbles => true, :cancelable => false}) ⇒ Event
Creates a new event of the given type, sets params to param hash. By default, the event bubbles and is not cancelable.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/glimr/event.rb', line 17 def initialize(type, params={:bubbles => true, :cancelable => false}) params = params.clone params[:bubbles] = true if params[:bubbles].nil? params[:cancelable] = false if params[:cancelable].nil? params[:time] ||= Time.now.to_f super(params) @type = type.to_sym @params = params @phase = :capture end |
Instance Attribute Details
#cancelled ⇒ Object (readonly)
Returns the value of attribute cancelled.
12 13 14 |
# File 'lib/glimr/event.rb', line 12 def cancelled @cancelled end |
#params ⇒ Object
Returns the value of attribute params.
13 14 15 |
# File 'lib/glimr/event.rb', line 13 def params @params end |
#phase ⇒ Object
Returns the value of attribute phase.
13 14 15 |
# File 'lib/glimr/event.rb', line 13 def phase @phase end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
12 13 14 |
# File 'lib/glimr/event.rb', line 12 def stopped @stopped end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/glimr/event.rb', line 12 def type @type end |
Instance Method Details
#prevent_default ⇒ Object
Cancels the event’s possible default behaviour.
34 35 36 |
# File 'lib/glimr/event.rb', line 34 def prevent_default @cancelled = true if cancelable end |
#stop_propagation ⇒ Object
Stops the handling of the event.
29 30 31 |
# File 'lib/glimr/event.rb', line 29 def stop_propagation @stopped = true end |