# 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](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_event.html "Event serves as a base class for user derived events."). 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(<a class="code" href="http://dev.doc.cgistudio.at/APILINK/group___behaviors_control.html#gga37959d0c8bd2f2c4ec4427a697be1365aeb7226ee20e9f17095571a522c5ff48e">ControlStateEnum::Pressed</a>, event.GetType() == <a class="code" href="http://dev.doc.cgistudio.at/APILINK/group___behaviors_control.html#gga37959d0c8bd2f2c4ec4427a697be1365aeb7226ee20e9f17095571a522c5ff48e">PressedEventType::Pressed</a>));
            }
        }
```

For a list with all Events which are used by Behaviors also check chapter <span style="color: rgb(230, 126, 35);">[Control Behaviors Events](https://doc316en.candera.eu/link/565#bkmrk-control-behaviors-ev)</span> . 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:

<div class="contents" id="bkmrk-directeventdispatchs"><div class="contents"><div class="contents"><div class="textblock">- **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.

</div></div></div></div><div drawio-diagram="2320"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1677058038.png" alt=""/></div>

<div class="contents" id="bkmrk--0"><div class="contents"><div class="textblock">  
</div></div></div>#### Event Dispatching Diagram

<div class="contents" id="bkmrk--1"><div class="contents"><div class="textblock"><div drawio-diagram="2321"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1677058061.png" alt=""/></div>

---

</div></div></div>#### **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 <span style="color: rgb(230, 126, 35);">[EventHandler Tab](https://doc316en.candera.eu/link/569#bkmrk-page-title)</span> .

##### Events

<div class="contents" id="bkmrk-class-candera%3A%3Aproce"><div class="textblock"><dl class="reflist"><dt><table border="1" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="background-color: rgb(194, 224, 244);"><dl class="reflist"><dt>Class [Candera::ProcessValueEvent](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_process_value_event.html)</dt></dl></td></tr><tr><td><dl class="reflist"><dd>ProcessValueEvent - Value Processed</dd></dl></td></tr></tbody></table>

<div class="contents"><table border="1" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="background-color: rgb(194, 224, 244);"><dl class="reflist"><dt>Class [CgiStudioControl::AnimationEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_animation_event.html)</dt></dl></td></tr><tr><td><dl class="reflist"><dd>AnimationEvent - Animation State Changed</dd></dl></td></tr></tbody></table>

</div></dt></dl></div></div><table border="1" id="bkmrk-class-cgistudiocontr" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ArTargetEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_ar_target_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ArTargetEvent - ArTargetEvent event</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-0" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::CaretPositionChangedEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_caret_position_changed_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">CaretPositionChangedEvent - Caret Position Changed</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-1" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ChangePropertyEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_change_property_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ChangePropertyEvent - Property Changed</td></tr></tbody></table>

<div class="contents" id="bkmrk-class-cgistudiocontr-2"><table border="1" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ChangeSelectionEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_change_selection_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ChangeSelectionEvent - Selection Changed</td></tr></tbody></table>

</div><div class="contents" id="bkmrk-class-cgistudiocontr-3"><div class="textblock"><dl class="reflist"><dt><div class="contents"><div class="textblock"><dl class="reflist"><dt><table border="1" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ChangeStateEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_change_state_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ChangeStateEvent - State Change Triggered</td></tr></tbody></table>

</dt><dt><table border="1" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ChangeValueEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_change_value_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ChangeValueEvent - Value Change Triggered</td></tr></tbody></table>

</dt><dt><table border="1" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ClickEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_click_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ClickEvent - Clicked</td></tr></tbody></table>

</dt><dt><table border="1" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ControlTimer::Event](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_control_timer_1_1_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ControlTimer::Event - Timer Expired</td></tr></tbody></table>

</dt></dl></div></div></dt></dl></div></div><table border="1" id="bkmrk-class-cgistudiocontr-4" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::DragDropEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_drag_drop_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">DragDropEvent - Drag and Drop</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-5" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::EnterExitEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_enter_exit_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">OnEnterExitEvent- On Enter Exit Edit</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-6" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::HoverEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_hover_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">HoverEvent - Hovered</td></tr></tbody></table>

<table border="1" id="bkmrk-member-cgistudiocont" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Member [CgiStudioControl::IntervalSwitchBehavior::OnEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_interval_switch_behavior.html#add5a525a0cc648e4588bda1c1158205d) (const [FeatStd::Event](http://dev.doc.cgistudio.at/APILINK/class_feat_std_1_1_event.html "Event serves as a base class for user derived events.") &amp;event, Candera::EventDispatchResult &amp;dispatchResult)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">to handle.</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-7" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::IntervalVisualizationEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_interval_visualization_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">IntervalVisualizationEvent - Interval State Changed</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-8" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::PoiUpdateEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_poi_update_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">PoiUpdateEvent - Poi update</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-9" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::PressedEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_pressed_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">PressedEvent - Pressed</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-10" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::RegisterSelectionEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_register_selection_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">RegisterSelectionEvent - Register Selection</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-11" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ScrollableDirectionChangedEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_scrollable_direction_changed_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ScrollableDirectionChangedEvent - Scroll Direction Changed</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-12" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::StateEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_state_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">StateEvent - State Changed</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-13" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::TrackingEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_tracking_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">TrackingEvent - Tracking event</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-14" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::ValueChangedEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_value_changed_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">ValueChangedEvent - Value Changed</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-15" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::VideoControlEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_video_control_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">VideoControlEvent - Video Control Event</td></tr></tbody></table>

<table border="1" id="bkmrk-class-cgistudiocontr-16" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="background-color: rgb(194, 224, 244); height: 29.7969px;"><dl class="reflist"><dt>Class [CgiStudioControl::VideoStateEvent](http://dev.doc.cgistudio.at/APILINK/class_cgi_studio_control_1_1_video_state_event.html)</dt></dl></td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;"><dl class="reflist"><dt><div class="contents"><div class="textblock"><dl class="reflist"><dd>VideoStateEvent - Video changed</dd></dl></div></div></dt><dd></dd></dl></td></tr></tbody></table>

<div class="contents" id="bkmrk--3"><div class="textblock"><dl class="reflist"><dt><div class="contents"><div class="textblock">---

<dl class="reflist"><dt>  
</dt></dl></div></div></dt></dl></div></div>