ferroui_controls/
combo_box_item.rs1use crate::primitives::TemplatedControlImpl;
2use crate::{ComboBox, ContentControlImpl, ControlImpl, ListBoxItem};
3use ferroui_base::input::{InputElement, InputElementImpl};
4use ferroui_base::interactivity::InteractiveImpl;
5use ferroui_base::layout::LayoutableImpl;
6use ferroui_base::reactive::ObservableExt;
7use ferroui_base::{
8 ferro_class, ferro_impl_classes, instantiate, FerroObject, FerroObjectExtensions, FerroObjectImpl,
9 FerroObjectImplExt, Ref, StyledElementImpl, VisualImpl,
10};
11
12#[repr(C)]
14pub struct ComboBoxItem {
15 base: ListBoxItem,
16}
17
18ferro_class!(ComboBoxItem: ListBoxItem);
19ferroui_base::ferro_class_info!(ComboBoxItem { new: ComboBoxItem::new });
20ferro_impl_classes!(
21 ComboBoxItem: StyledElementImpl,
22 VisualImpl,
23 LayoutableImpl,
24 InteractiveImpl,
25 InputElementImpl,
26 ControlImpl,
27 TemplatedControlImpl,
28 ContentControlImpl
29);
30
31impl FerroObjectImpl for ComboBoxItem {
32 fn constructed(this: &Self) {
33 Self::parent_constructed(this);
34
35 let weak = this.to_ref().downgrade();
36 let object: &FerroObject = this;
37 FerroObjectExtensions::get_observable(object, InputElement::is_focused_property()).subscribe_fn(move |focused| {
38 if focused {
39 let Some(this) = weak.upgrade() else { return };
40 if let Some(parent) = this.parent().and_then(|parent| parent.cast::<ComboBox>()) {
41 parent.item_focused(&this);
42 }
43 }
44 });
45 }
46}
47
48impl ComboBoxItem {
49 pub fn construct() -> Self {
51 Self { base: ListBoxItem::construct() }
52 }
53
54 pub fn new() -> Ref<Self> {
55 instantiate(Self::construct())
56 }
57
58 fn static_constructor() {
59 crate::automation::AutomationProperties::control_type_override_property()
60 .override_default_value::<ComboBoxItem>(Some(crate::automation::peers::AutomationControlType::ComboBoxItem));
61 }
62}