ofxDOM
A DOM Level 3 Events implementation for openFrameworks.
ofx::DOM::EventArgs Class Reference

The base type describing a named Element Event. More...

#include <Events.h>

Inheritance diagram for ofx::DOM::EventArgs:
ofx::DOM::DragDropEventArgs ofx::DOM::FocusEventArgs ofx::DOM::UIEventArgs ofx::DOM::KeyboardUIEventArgs ofx::DOM::PointerCaptureUIEventArgs ofx::DOM::PointerUIEventArgs

Public Types

enum  Phase { Phase::NONE = 0, Phase::CAPTURING_PHASE = 1, Phase::AT_TARGET = 2, Phase::BUBBLING_PHASE = 3 }
 

Public Member Functions

 EventArgs (const std::string &type, Element *source, Element *target, bool bubbles, bool cancelable, uint64_t timestamp)
 Create EventArgs with a type. More...
 
 EventArgs (const std::string &type, Element *source, Element *target, Element *relatedTarget, bool bubbles, bool cancelable, uint64_t timestamp)
 Create EventArgs with a type. More...
 
virtual ~EventArgs ()
 Destroy the EventArgs.
 
const std::string & type () const
 Get the event type. More...
 
void stopPropagation ()
 Stop the propagation of the event. More...
 
void stopImmediatePropagation ()
 
void preventDefault ()
 Prevent any default actions associated with the event. More...
 
bool isCancelled () const
 
bool isDefaultPrevented () const
 
void setPhase (Phase phase)
 Set the Phase of the event. More...
 
Phase getPhase () const
 
bool bubbles () const
 Determine if the event has a bubbling phase. More...
 
bool isCancelable () const
 
Elementsource ()
 
Elementtarget ()
 
ElementrelatedTarget ()
 
ElementgetCurrentTarget ()
 
const ElementgetCurrentTarget () const
 
void setCurrentTarget (Element *target)
 Set the current target Element. More...
 
uint64_t timestamp () const
 
std::string toString () const
 A utility method to print get the Event as a std::string. More...
 

Protected Attributes

std::string _type
 The name of the event (case-insensitive).
 
Element_source = nullptr
 The source of the event.
 
Element_target = nullptr
 The event's target.
 
Element_relatedTarget = nullptr
 The event's related target.
 
bool _bubbles = true
 Used to indicate whether or not an event is a bubbling event. If the event can bubble the value is true, else the value is false.
 
bool _cancelable = true
 Used to indicate whether propgation was stopped. The currentTarget will indicate which target stopped propagation.
 
bool _defaultPrevented = false
 Used to indicated.
 
Element_currentTaget = nullptr
 Used to indicate the EventTarget whose EventListeners are currently being processed. This is particularly useful during capturing and bubbling.
 
Phase _phase = Phase::NONE
 Used to indicate which phase of event flow is currently being evaluated.
 
bool _canceled = false
 Used to indicate if an event is canceled.
 
uint64_t _timestamp = 0
 Used to specify the time (in milliseconds relative to the epoch) at which the event was created. More...
 

Friends

class Document
 The Document class has access to Event data.
 

Detailed Description

The base type describing a named Element Event.

See also
http://www.w3.org/TR/DOM-Level-3-Events/

Member Enumeration Documentation

Enumerator
NONE 

Events not currently dispatched are in this phase.

CAPTURING_PHASE 

When an event is dispatched to an object that participates in a tree it will be in this phase before it reaches its target attribute value.

AT_TARGET 

When an event is dispatched it will be in this phase on its target attribute value.

BUBBLING_PHASE 

When an event is dispatched to an object that participates in a tree it will be in this phase after it reaches its target attribute value.

Constructor & Destructor Documentation

ofx::DOM::EventArgs::EventArgs ( const std::string &  type,
Element source,
Element target,
bool  bubbles,
bool  cancelable,
uint64_t  timestamp 
)

Create EventArgs with a type.

Parameters
typeThe event type string (case-insensitive).
sourceThe source of the event.
targetThe target element.
bubblesTrue iff the argument bubbles after AT_TARGET phase.
cancelableTrue iff the event can be cancelled by a listener.
timestampThe timestamp of the event.
ofx::DOM::EventArgs::EventArgs ( const std::string &  type,
Element source,
Element target,
Element relatedTarget,
bool  bubbles,
bool  cancelable,
uint64_t  timestamp 
)

Create EventArgs with a type.

Parameters
typeThe event type string (case-insensitive).
sourceThe source of the event.
targetThe target element.
bubblesTrue iff the argument bubbles after AT_TARGET phase.
cancelableTrue iff the event can be cancelled by a listener.
timestampThe timestamp of the event.

Member Function Documentation

bool ofx::DOM::EventArgs::bubbles ( ) const

Determine if the event has a bubbling phase.

Returns
true iff the event should bubble.
Element * ofx::DOM::EventArgs::getCurrentTarget ( )
Returns
a pointer to the current target Element.
const Element * ofx::DOM::EventArgs::getCurrentTarget ( ) const
Returns
a pointer to the current target Element.
EventArgs::Phase ofx::DOM::EventArgs::getPhase ( ) const
Returns
the Phase of the event.
bool ofx::DOM::EventArgs::isCancelable ( ) const
Returns
true iff the Event can be cancelled.
bool ofx::DOM::EventArgs::isCancelled ( ) const
Returns
true iff the event was cancelled.
bool ofx::DOM::EventArgs::isDefaultPrevented ( ) const
Returns
true iff the default activity was prevented.
void ofx::DOM::EventArgs::preventDefault ( )

Prevent any default actions associated with the event.

For some events, there are default actions. Calling preventDefault will tell the event dispatcher that it should not call the default action after the event has been dispatched. This is different from stopPropagation. Calling stopPropagation does not prevent the default action from taking place. To stop propagation and prevent the default, both methods must be called.

Element * ofx::DOM::EventArgs::relatedTarget ( )
Returns
the related target Element.
void ofx::DOM::EventArgs::setCurrentTarget ( Element target)

Set the current target Element.

Parameters
targetThe current target Element.
void ofx::DOM::EventArgs::setPhase ( Phase  phase)

Set the Phase of the event.

Parameters
phaseThe phase to set.
Element * ofx::DOM::EventArgs::source ( )
Returns
the source Element.
void ofx::DOM::EventArgs::stopPropagation ( )

Stop the propagation of the event.

The stopPropagation method is used prevent further propagation of an event during event flow. If this method is called by any EventListener the event will cease propagating through the tree. The event will complete dispatch to all listeners on the current EventTarget before event flow stops. This method may be used during any stage of event flow.

Element * ofx::DOM::EventArgs::target ( )
Returns
the target Element.
uint64_t ofx::DOM::EventArgs::timestamp ( ) const
Returns
the timestamp (in milliseconds relative to the epoch).
std::string ofx::DOM::EventArgs::toString ( ) const

A utility method to print get the Event as a std::string.

Returns
The Event as a std::string.
Note
Not for serialization.
const std::string & ofx::DOM::EventArgs::type ( ) const

Get the event type.

Returns
the event type string.

Member Data Documentation

uint64_t ofx::DOM::EventArgs::_timestamp = 0
protected

Used to specify the time (in milliseconds relative to the epoch) at which the event was created.

Due to the fact that some systems may not provide this information the value of timeStamp may be not available for all events. When not available, a value of 0 will be returned. Examples of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970.


The documentation for this class was generated from the following files: