You.i Engine
CYIEventTarget Class Reference

Detailed Description

Represents an event target of type YI_SPECIAL_EVENT_TARGET_TYPE.

Note
CYISceneNode is an event target.

#include <event/YiEventTarget.h>

Inheritance diagram for CYIEventTarget:

Public Types

enum  EVENT_PHASE {
  BUBBLE,
  CAPTURE
}
 

Public Member Functions

 CYIEventTarget ()
 
virtual ~CYIEventTarget ()
 
bool AddEventListener (YI_EVENT_TYPE eEventType, CYIEventHandler *pListener, EVENT_PHASE ePhase=BUBBLE)
 
bool RemoveEventListener (YI_EVENT_TYPE eEventType, CYIEventHandler *pListener, EVENT_PHASE ePhase=BUBBLE)
 
virtual bool ProcessEvent (const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent)
 
void SetSpecialTypeFlag (YI_SPECIAL_EVENT_TARGET_TYPE eType)
 
void ClearSpecialTypeFlag (YI_SPECIAL_EVENT_TARGET_TYPE eType)
 
YI_SPECIAL_EVENT_TARGET_TYPE GetSpecialTypes () const
 
- Public Member Functions inherited from CYIScriptableRTTIObject
 CYIScriptableRTTIObject ()
 
virtual ~CYIScriptableRTTIObject ()
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const override
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 

Protected Attributes

YI_SPECIAL_EVENT_TARGET_TYPE m_eSpecialTypes
 
std::vector< EventListenerEntry > m_listeners
 

Additional Inherited Members

- Protected Member Functions inherited from CYIScriptableRTTIObject
virtual std::pair< const CYIRuntimeTypeInfo *, const void * > GetRuntimeTypeInfoWithObject () const =0
 

Member Enumeration Documentation

Enumerator
BUBBLE 

The bubble phase walks up the scene tree and allows each node from target to parent to process the next event with this phase set.

CAPTURE 

The capture phase walks down the scene tree and allows each node from parent to target process the next event with this phase set.

Constructor & Destructor Documentation

CYIEventTarget::CYIEventTarget ( )
virtual CYIEventTarget::~CYIEventTarget ( )
virtual

Member Function Documentation

bool CYIEventTarget::AddEventListener ( YI_EVENT_TYPE  eEventType,
CYIEventHandler pListener,
EVENT_PHASE  ePhase = BUBBLE 
)

Registers a new event listener for the specified event type. If ePhase is set to 'CAPTURE', pListener is registered for the CAPTURE event phase (as well as AT_TARGET). Otherwise, listener is registered for the BUBBLE event phase (as well as AT_TARGET). Returns true if the listener was successfully registered.

Note
The event target does not take ownership of pListener.
Warning
It is unsafe to add an event listener inside of the following methods:
void CYIEventTarget::ClearSpecialTypeFlag ( YI_SPECIAL_EVENT_TARGET_TYPE  eType)
YI_SPECIAL_EVENT_TARGET_TYPE CYIEventTarget::GetSpecialTypes ( ) const
virtual bool CYIEventTarget::ProcessEvent ( const std::shared_ptr< CYIEventDispatcher > &  pDispatcher,
CYIEvent pEvent 
)
virtual

Notifies this event target of an incoming event. Calls all the relevant listeners based on event type and phase. Returns true if any of the listeners' handleEvent() function returned true.

Reimplemented in CYISceneNode, and CYISceneView.

bool CYIEventTarget::RemoveEventListener ( YI_EVENT_TYPE  eEventType,
CYIEventHandler pListener,
EVENT_PHASE  ePhase = BUBBLE 
)
void CYIEventTarget::SetSpecialTypeFlag ( YI_SPECIAL_EVENT_TARGET_TYPE  eType)

Member Data Documentation

YI_SPECIAL_EVENT_TARGET_TYPE CYIEventTarget::m_eSpecialTypes
protected
std::vector<EventListenerEntry> CYIEventTarget::m_listeners
protected

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