ferroui_xaml_interactivity/triggers/
interactive_trigger_base.rs1use crate::{Interaction, StyledElementBehaviorImpl, StyledElementTriggerOfT};
4use ferroui_base::interactivity::{Interactive, RoutingStrategies};
5use ferroui_base::{ferro_class, ferro_properties, BoxedValue, FerroObjectImpl, FerroProperty, StyledElementImpl, StyledProperty};
6use std::rc::Rc;
7
8#[repr(C)]
11pub struct InteractiveTriggerBase {
12 base: StyledElementTriggerOfT,
13}
14
15ferro_class!(InteractiveTriggerBase: StyledElementTriggerOfT);
16ferroui_base::ferro_impl_classes!(InteractiveTriggerBase: FerroObjectImpl, StyledElementImpl, StyledElementBehaviorImpl);
17
18ferro_properties! {
19 impl InteractiveTriggerBase {
20 pub fn routing_strategies_property() -> StyledProperty<RoutingStrategies> {
22 FerroProperty::register::<InteractiveTriggerBase, _>("RoutingStrategies", RoutingStrategies::BUBBLE)
23 }
24 }
25}
26
27impl InteractiveTriggerBase {
28 pub fn construct() -> Self {
30 Self { base: StyledElementTriggerOfT::construct(<Interactive as ferroui_base::StaticType>::TYPE) }
31 }
32
33 pub fn routing_strategies(&self) -> RoutingStrategies {
35 self.get_value(Self::routing_strategies_property())
36 }
37
38 pub fn set_routing_strategies(&self, value: RoutingStrategies) {
39 self.set_value(Self::routing_strategies_property(), value)
40 }
41
42 pub fn execute(&self, parameter: Option<&BoxedValue>) {
44 if !self.is_enabled() {
45 return;
46 }
47
48 let sender = self.associated_object().map(|associated_object| Rc::new(associated_object) as BoxedValue);
49 Interaction::execute_actions(sender.as_ref(), self.actions().as_ref(), parameter);
50 }
51}