Behaviors and Events
This chapter explains how the Event-System in Behaviors work.
General
Behaviors communicate via Events with each other and with other components of the application. For each action a specific event is implemented. An Event can carry any data or none at all. For a custom Event simply derive from FeatStd::Event. Each Behavior can return an event-result after handling an Event in the "OnEvent"-method. Behaviors are using unique identifiers (FeatStd::Internal::Identifier) to identify the sender of an event.
void OnPressedEvent(const PressedEvent& event, Candera::EventDispatchResult& /*dispatchResult*/)
{
if (event.GetSender() == m_behavior.GetIdentifier()) {
static_cast<void>(m_behavior.SetState(ControlStateEnum::Pressed, event.GetType() == PressedEventType::Pressed));
}
}
For a list with all Events which are used by Behaviors also check chapter Control Behaviors Events . There you can also find their readable names (names in SC).
Event-dispatching
The Behavior base-class implements DispatchEvent-functions. Events are dispatched on a Node using one of the available EventDispatchStrategy objects. An Event is passed to all OnEvent function of all Behaviors. The following dispatch strategies are available:
- DirectEventDispatchStrategy: Only the behaviors of the node will receive the event.
- BroadcastEventDispatchStrategy: The event will be first dispatched to the current node then to all child nodes.
- BubbleEventDispatchStrategy: The event will be dispatched from the current node to the parent and so on until the root node is reached.
- TunnelEventDispatchStrategy: The event will be dispatched from the root node to the current node.
Event Dispatching Diagram
Control Behaviors Events
This chapter gives an overview of the most important control behaviors events. Furthermore they are listed with their readable names (names in SC). For further information of how to use them in SC see chapter EventHandler Tab .
Events
-
- AnimationEvent - Animation State Changed