ferroui_xaml_interactions_custom/validation/
text_box_validation_behavior.rs1use super::property_validation_behavior::PropertyValidationBehavior;
4use ferroui_base::{
5 ferro_class, ferro_class_info, instantiate, FerroObjectImpl, FerroObjectImplExt, Ref, StaticType, StyledElementImpl,
6};
7use ferroui_controls::TextBox;
8use ferroui_xaml_interactivity::{DisposingBehaviorImpl, StyledElementBehaviorImpl};
9use std::any::TypeId;
10
11#[repr(C)]
13pub struct TextBoxValidationBehavior {
14 base: PropertyValidationBehavior,
15}
16
17ferro_class!(TextBoxValidationBehavior: PropertyValidationBehavior);
18ferro_class_info!(TextBoxValidationBehavior { new: TextBoxValidationBehavior::new });
19ferroui_base::ferro_impl_classes!(TextBoxValidationBehavior: StyledElementImpl, StyledElementBehaviorImpl, DisposingBehaviorImpl);
20
21ferroui_base::ferro_overrides! {
22 impl FerroObjectImpl for TextBoxValidationBehavior {
23 fn constructed(this: &Self) {
25 Self::parent_constructed(this);
26
27 this.set_property(Some(TextBox::text_property().as_property()));
28 }
29 }
30}
31
32impl TextBoxValidationBehavior {
33 pub fn construct() -> Self {
35 Self { base: PropertyValidationBehavior::construct(<TextBox as StaticType>::TYPE, TypeId::of::<Option<String>>()) }
36 }
37
38 pub fn new() -> Ref<Self> {
40 instantiate(Self::construct())
41 }
42}