Control
struct · ferroui-controls · v0.5.0
struct Control
Base class for controls.
The control class extends InputElement and adds the following
features:
- A
Tagproperty to allow user-defined data to be attached to the control.
Members
find_data_templateTYPEto_refget_template_focus_targeton_loadedon_unloadedon_size_changedon_create_automation_peereffective_context_flyoutcontext_request_generationfocus_adorner_propertytag_propertycontext_menu_propertycontext_flyout_propertyrequest_bring_into_view_eventloaded_eventunloaded_eventsize_changed_eventconstructnewfocus_adornerset_focus_adornerdata_templatesis_data_templates_initializedcontext_menuset_context_menucontext_flyoutset_context_flyoutis_loadedtagset_tagloadedunloadedsize_changedboxedfrom_boxedlogical_from_boxedensure_initializedbring_into_viewbring_into_view_rectfind_controlget_controlset_pseudo_class_from
find_data_template
fn find_data_template(self: &Self, data: Option<&BoxedValue>, primary: Option<&Rc<dyn IDataTemplate>>) -> Option<Rc<dyn IDataTemplate>>
Find a data template that matches a piece of data.
primary is an optional primary template that can display the data.
Returns the data template or None if no matching data template was
found.
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<Control>
Returns a strong reference to this object.
get_template_focus_target
fn get_template_focus_target(self: &Self) -> Option<Ref<Control>>
Gets the element that receives the focus adorner.
on_loaded
fn on_loaded(self: &Self, e: &RoutedEventArgs)
Raises the Loaded event.
on_unloaded
fn on_unloaded(self: &Self, e: &RoutedEventArgs)
Raises the Unloaded event.
on_size_changed
fn on_size_changed(self: &Self, e: &SizeChangedEventArgs)
Raises the SizeChanged event.
on_create_automation_peer
fn on_create_automation_peer(self: &Self) -> Ref<AutomationPeer>
Returns a new, type-specific automation peer implementation for the control.
effective_context_flyout
fn effective_context_flyout(self: &Self, for_request: bool) -> Option<Ref<FlyoutBase>>
The flyout a context request on the control shows (for_request), or
that its keys and cancellation dismiss: ContextFlyout by default. A
control whose context flyout belongs to another element (a linked text
container) resolves it here, and may show none for a request. An
addition (docs/porting/DEVIATIONS.md, Popup).
context_request_generation
fn context_request_generation(self: &Self) -> Option<u64>
A counter the control advances when it raises a newer context request
of its own while an older one is being handled; None by default. The
context menu and flyout drop the older request when it changed. An
addition (docs/porting/DEVIATIONS.md, Popup).
focus_adorner_property
fn focus_adorner_property() -> &'static StyledProperty<Option<Rc<dyn ITemplateOf<Option<Ref<Control>>>>>>
Defines the FocusAdorner property.
tag_property
fn tag_property() -> &'static StyledProperty<Option<BoxedValue>>
Defines the Tag property.
context_menu_property
fn context_menu_property() -> &'static StyledProperty<Option<Ref<ContextMenu>>>
Defines the ContextMenu property.
context_flyout_property
fn context_flyout_property() -> &'static StyledProperty<Option<Ref<FlyoutBase>>>
Defines the ContextFlyout property.
request_bring_into_view_event
fn request_bring_into_view_event() -> &'static RoutedEvent<RequestBringIntoViewEventArgs>
Event raised when an element wishes to be scrolled into view.
loaded_event
fn loaded_event() -> &'static RoutedEvent<RoutedEventArgs>
Defines the Loaded event.
unloaded_event
fn unloaded_event() -> &'static RoutedEvent<RoutedEventArgs>
Defines the Unloaded event.
size_changed_event
fn size_changed_event() -> &'static RoutedEvent<SizeChangedEventArgs>
Defines the SizeChanged event.
construct
fn construct() -> Self
Creates the class data; see ferroui_base::FerroObject::construct.
new
fn new() -> Ref<Self>
focus_adorner
fn focus_adorner(self: &Self) -> Option<Rc<dyn ITemplateOf<Option<Ref<Control>>>>>
The control's focus adorner.
set_focus_adorner
fn set_focus_adorner(self: &Self, value: Option<Rc<dyn ITemplateOf<Option<Ref<Control>>>>>)
data_templates
fn data_templates(self: &Self) -> DataTemplates
The data templates for the control.
Each control may define data templates which are applied to the control itself and its children.
is_data_templates_initialized
fn is_data_templates_initialized(self: &Self) -> bool
Whether the data templates collection has been created.
context_menu
fn context_menu(self: &Self) -> Option<Ref<ContextMenu>>
A context menu to the control.
set_context_menu
fn set_context_menu(self: &Self, value: impl Into<Nullable<ContextMenu>>)
context_flyout
fn context_flyout(self: &Self) -> Option<Ref<FlyoutBase>>
A context flyout to the control.
set_context_flyout
fn set_context_flyout(self: &Self, value: impl Into<Nullable<FlyoutBase>>)
is_loaded
fn is_loaded(self: &Self) -> bool
Whether the control is fully constructed in the visual tree and both layout and render are complete.
This is set to true while raising the Loaded event.
tag
fn tag(self: &Self) -> Option<BoxedValue>
A user-defined object attached to the control.
set_tag
fn set_tag(self: &Self, value: Option<BoxedValue>)
loaded
fn loaded(self: &Self, handler: impl Fn(&Interactive, &RoutedEventArgs) -> () + 'static) -> RoutedEventHandlerToken
Occurs when the control has been fully constructed in the visual tree and both layout and render are complete.
This event is guaranteed to occur after the control template is
applied and references to objects created after the template is
applied are available. This makes it different from
on_attached_to_visual_tree which doesn't have these references. This
event occurs at the latest possible time in the control creation
life-cycle.
unloaded
fn unloaded(self: &Self, handler: impl Fn(&Interactive, &RoutedEventArgs) -> () + 'static) -> RoutedEventHandlerToken
Occurs when the control is removed from the visual tree.
This is API symmetrical with loaded and exists for compatibility
with other XAML frameworks; however, it behaves the same as
on_detached_from_visual_tree.
size_changed
fn size_changed(self: &Self, handler: impl Fn(&Interactive, &SizeChangedEventArgs) -> () + 'static) -> RoutedEventHandlerToken
Occurs when the bounds (actual size) of the control have changed.
boxed
fn boxed(control: impl IntoRef<Control>) -> BoxedValue
The boxing convention for a control held in an untyped value (a
Content, a Tag, an item): the value holds a Ref<Control>.
from_boxed
fn from_boxed(value: &BoxedValue) -> Option<Ref<Control>>
The control held by an untyped value, if it holds one (value as Control upstream). See boxed.
The value is a control whatever handle it holds it by: the
Ref<Control> of the boxing convention, the handle of another class
of the object model (a Ref<Border>, a Ref<FerroObject>), or an
interface handle that holds an object
(ValueTypes::register_interface_object); a value that a binding
passes on keeps the static type of its source.
logical_from_boxed
fn logical_from_boxed(value: &BoxedValue) -> Option<Ref<StyledElement>>
The logical element held by an untyped value, if it holds one
(value as ILogical upstream): an element held by any handle, as
from_boxed takes it.
ensure_initialized
fn ensure_initialized(self: &Self)
Ensures that the control is initialized and laid out when it is used as the source of a visual brush while not attached to a visual root.
bring_into_view
fn bring_into_view(self: &Self)
Tries to bring the control into view.
bring_into_view_rect
fn bring_into_view_rect(self: &Self, rect: Rect)
Tries to bring the control into view.
rect is the area of the control to being into view.
find_control
fn find_control<T: ObjectType>(self: &Self, name: &str) -> Option<Ref<T>>
Finds the named control in the scope of the specified control.
Returns the control or None if not found; panics if the control has
no parent name scope or the named control is of a different class.
get_control
fn get_control<T: ObjectType>(self: &Self, name: &str) -> Ref<T>
Gets the named control in the scope of the specified control.
Panics if the control has no parent name scope or the named control is not found.
set_pseudo_class_from
fn set_pseudo_class_from(self: &Self, name: &str, trigger: &dyn IObservable<bool>) -> Subscription
Sets a pseudoclass of the control depending on an observable trigger.
Dropping the returned guard stops following the trigger; Subscription::detach keeps it
for the life of the trigger.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeControlImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<Control>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleStyledElementImplLayoutableImplInteractiveImplFerroObjectImplVisualImplInputElementImplControlImplIDataTemplateHostISetterValue
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.