FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    NumberBox

    struct · ferroui-controls · v0.5.0

    struct NumberBox
    

    A text box for numbers (WinUI's NumberBox): a value of type f64, NaN when the box is empty, with a range, steps, wrapping, expressions and spin buttons.

    The text is committed when the box loses the focus, on Enter and before a step: it is parsed with the NumberFormatter, or evaluated as an expression (utils::number_expression) when AcceptsExpression is set. Up and Down (and the spin buttons and the mouse wheel) step by SmallChange, PageUp and PageDown by LargeChange; Escape restores the text of the value.

    The template is the control theme of the WinUI theme (Controls/NumberBox.xaml, from WinUI's NumberBox.xaml), with WinUI's parts: the text box InputBox, the spin buttons UpSpinButton and DownSpinButton, the popup UpDownPopup with PopupUpSpinButton and PopupDownSpinButton, and HeaderContentPresenter. The control sets WinUI's visual states as pseudo-classes: :spinbuttonsvisible and :spinbuttonspopup (SpinButtonStates; neither is SpinButtonsCollapsed), :upspinbuttondisabled and :downspinbuttondisabled. The Fluent and Simple themes have no template for it (docs/porting/winui-controls.md, section 5.1).

    Missing (docs/porting/winui-controls.md, Input): InputScope, SelectionFlyout, SelectionHighlightColor, TextReadingOrder and PreventKeyboardDisplayOnProgrammaticFocus.

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<NumberBox>
    

    Returns a strong reference to this object.

    Source

    minimum_property

    fn minimum_property() -> &'static StyledProperty<f64>
    

    Defines the Minimum property: the smallest value. The largest negative f64 by default.

    Source

    maximum_property

    fn maximum_property() -> &'static StyledProperty<f64>
    

    Defines the Maximum property: the largest value. The largest f64 by default.

    Source

    value_property

    fn value_property() -> &'static StyledProperty<f64>
    

    Defines the Value property: the number, NaN when the box is empty (the default).

    Source

    small_change_property

    fn small_change_property() -> &'static StyledProperty<f64>
    

    Defines the SmallChange property: the step of the arrow keys, the spin buttons and the mouse wheel. 1 by default.

    Source

    large_change_property

    fn large_change_property() -> &'static StyledProperty<f64>
    

    Defines the LargeChange property: the step of PageUp and PageDown. 10 by default.

    Source

    text_property

    fn text_property() -> &'static StyledProperty<String>
    

    Defines the Text property: the text of the value. Setting it commits it as input.

    Source

    header_property

    fn header_property() -> &'static StyledProperty<Option<BoxedValue>>
    

    Defines the Header property: the content above the box.

    Source

    header_template_property

    fn header_template_property() -> &'static StyledProperty<Option<Rc<dyn IDataTemplate>>>
    

    Defines the HeaderTemplate property: the template of the header.

    Source

    placeholder_text_property

    fn placeholder_text_property() -> &'static StyledProperty<String>
    

    Defines the PlaceholderText property: the text shown while the box is empty.

    Source

    text_alignment_property

    fn text_alignment_property() -> &'static StyledProperty<TextAlignment>
    

    Defines the TextAlignment property: the alignment of the text. Left by default.

    Source

    description_property

    fn description_property() -> &'static StyledProperty<Option<BoxedValue>>
    

    Defines the Description property: the content below the box.

    Source

    validation_mode_property

    fn validation_mode_property() -> &'static StyledProperty<NumberBoxValidationMode>
    

    Defines the ValidationMode property. InvalidInputOverwritten by default.

    Source

    spin_button_placement_mode_property

    fn spin_button_placement_mode_property() -> &'static StyledProperty<NumberBoxSpinButtonPlacementMode>
    

    Defines the SpinButtonPlacementMode property. Hidden by default.

    Source

    is_wrap_enabled_property

    fn is_wrap_enabled_property() -> &'static StyledProperty<bool>
    

    Defines the IsWrapEnabled property: whether a step past one end of the range goes to the other end. false by default.

    Source

    accepts_expression_property

    fn accepts_expression_property() -> &'static StyledProperty<bool>
    

    Defines the AcceptsExpression property: whether the text is evaluated as an arithmetic expression. false by default.

    Source

    number_formatter_property

    fn number_formatter_property() -> &'static StyledProperty<Rc<dyn INumberBoxNumberFormatter>>
    

    Defines the NumberFormatter property: the formatter of the value and parser of the text. InvariantNumberBoxNumberFormatter by default.

    Source

    construct

    fn construct() -> Self
    

    Creates the class data; see ferroui_base::FerroObject::construct.

    Source

    new

    fn new() -> Ref<Self>
    

    Source

    minimum

    fn minimum(self: &Self) -> f64
    

    Gets the smallest value.

    Source

    set_minimum

    fn set_minimum(self: &Self, value: f64)
    

    Sets the smallest value.

    Source

    maximum

    fn maximum(self: &Self) -> f64
    

    Gets the largest value.

    Source

    set_maximum

    fn set_maximum(self: &Self, value: f64)
    

    Sets the largest value.

    Source

    value

    fn value(self: &Self) -> f64
    

    Gets the value: NaN when the box is empty.

    Source

    set_numeric_value

    fn set_numeric_value(self: &Self, value: f64)
    

    Sets the value (WinUI's Value setter). Setting NaN while the value is NaN does nothing: "we are using nan as a value to represent value not set (cleared)", and NaN is not equal to itself.

    Source

    small_change

    fn small_change(self: &Self) -> f64
    

    Gets the step of the arrow keys, the spin buttons and the mouse wheel.

    Source

    set_small_change

    fn set_small_change(self: &Self, value: f64)
    

    Sets the step of the arrow keys, the spin buttons and the mouse wheel.

    Source

    large_change

    fn large_change(self: &Self) -> f64
    

    Gets the step of PageUp and PageDown.

    Source

    set_large_change

    fn set_large_change(self: &Self, value: f64)
    

    Sets the step of PageUp and PageDown.

    Source

    text

    fn text(self: &Self) -> String
    

    Gets the text of the value.

    Source

    set_text

    fn set_text(self: &Self, value: impl Into<String>)
    

    Sets the text; it is committed as input.

    Source

    header

    fn header(self: &Self) -> Option<BoxedValue>
    

    Gets the header.

    Source

    set_header

    fn set_header(self: &Self, value: Option<BoxedValue>)
    

    Sets the header.

    Source

    header_template

    fn header_template(self: &Self) -> Option<Rc<dyn IDataTemplate>>
    

    Gets the template of the header.

    Source

    set_header_template

    fn set_header_template(self: &Self, value: Option<Rc<dyn IDataTemplate>>)
    

    Sets the template of the header.

    Source

    placeholder_text

    fn placeholder_text(self: &Self) -> String
    

    Gets the text shown while the box is empty.

    Source

    set_placeholder_text

    fn set_placeholder_text(self: &Self, value: impl Into<String>)
    

    Sets the text shown while the box is empty.

    Source

    text_alignment

    fn text_alignment(self: &Self) -> TextAlignment
    

    Gets the alignment of the text.

    Source

    set_text_alignment

    fn set_text_alignment(self: &Self, value: TextAlignment)
    

    Sets the alignment of the text.

    Source

    description

    fn description(self: &Self) -> Option<BoxedValue>
    

    Gets the content below the box.

    Source

    set_description

    fn set_description(self: &Self, value: Option<BoxedValue>)
    

    Sets the content below the box.

    Source

    validation_mode

    fn validation_mode(self: &Self) -> NumberBoxValidationMode
    

    Gets the validation mode.

    Source

    set_validation_mode

    fn set_validation_mode(self: &Self, value: NumberBoxValidationMode)
    

    Sets the validation mode.

    Source

    spin_button_placement_mode

    fn spin_button_placement_mode(self: &Self) -> NumberBoxSpinButtonPlacementMode
    

    Gets where the spin buttons are.

    Source

    set_spin_button_placement_mode

    fn set_spin_button_placement_mode(self: &Self, value: NumberBoxSpinButtonPlacementMode)
    

    Sets where the spin buttons are.

    Source

    is_wrap_enabled

    fn is_wrap_enabled(self: &Self) -> bool
    

    Gets whether a step past one end of the range goes to the other end.

    Source

    set_is_wrap_enabled

    fn set_is_wrap_enabled(self: &Self, value: bool)
    

    Sets whether a step past one end of the range goes to the other end.

    Source

    accepts_expression

    fn accepts_expression(self: &Self) -> bool
    

    Gets whether the text is evaluated as an arithmetic expression.

    Source

    set_accepts_expression

    fn set_accepts_expression(self: &Self, value: bool)
    

    Sets whether the text is evaluated as an arithmetic expression.

    Source

    number_formatter

    fn number_formatter(self: &Self) -> Rc<dyn INumberBoxNumberFormatter>
    

    Gets the formatter of the value and parser of the text.

    Source

    set_number_formatter

    fn set_number_formatter(self: &Self, value: Rc<dyn INumberBoxNumberFormatter>)
    

    Sets the formatter of the value and parser of the text.

    Source

    value_changed

    fn value_changed(self: &Self, handler: impl Fn(&NumberBoxValueChangedEventArgs) -> () + 'static) -> Subscription
    

    Adds a handler of the ValueChanged event, raised after a change of the value with the value before it and the coerced new value.

    Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the box.

    Source

    validate_input

    fn validate_input(self: &Self) -> bool
    

    Commits the text of the box (WinUI's ValidateInput): empty text clears the value; text that is a number (or, with AcceptsExpression, an expression) becomes the value and is formatted again; other text is replaced with the text of the value unless validation is disabled. Returns whether the text was a number or empty.

    Deviation (docs/porting/winui-controls.md, Input): without a template (no text box) the text committed is the Text property.

    Source

    step_value

    fn step_value(self: &Self, change: f64)
    

    Commits the text and adds change to the value (WinUI's StepValue), wrapping past the ends of the range when IsWrapEnabled is set. Nothing happens while the box is empty.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.