pub struct NumberField { /* private fields */ }Expand description
A typed number. While it has focus it shows what is being typed, and without
focus the formatted value, such as R$ 1.234,50. Text that is not a number in
range stays visible for fixing and leaves the value alone. Up and Down step.
The separators come from crate::Labels, through crate::Localized.
use ravenrs_reactive::State;
use ravenrs_widgets::{NumberField, Ui};
let price = State::new(Some(1234.5));
let field = NumberField::new(price.binding()).decimals(2).range(0.0, 1e9).prefix("R$ ");
let mut ui = Ui::new(field, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl NumberField
impl NumberField
Sourcepub fn on_leave(self, handler: impl Fn() + 'static) -> NumberField
pub fn on_leave(self, handler: impl Fn() + 'static) -> NumberField
Called when the keyboard goes elsewhere after being here.
Sourcepub fn new(value: Binding<Option<f64>>) -> NumberField
pub fn new(value: Binding<Option<f64>>) -> NumberField
A field bound to value, unbounded, with no decimals; None is empty.
Sourcepub fn money(
cents: Binding<Option<i64>>,
prefix: impl Into<String>,
) -> NumberField
pub fn money( cents: Binding<Option<i64>>, prefix: impl Into<String>, ) -> NumberField
A field for money held as a whole number of cents: exact, two decimals,
showing prefix, such as "R$ ".
Sourcepub fn range(self, min: f64, max: f64) -> NumberField
pub fn range(self, min: f64, max: f64) -> NumberField
Accepts only min..=max.
Sourcepub fn step(self, step: f64) -> NumberField
pub fn step(self, step: f64) -> NumberField
How much Up, Down and the buttons change the value. 1 by default.
Sourcepub fn decimals(self, decimals: usize) -> NumberField
pub fn decimals(self, decimals: usize) -> NumberField
Digits shown after the decimal separator without focus. 0 by default.
Sourcepub fn grouping(self, grouping: bool) -> NumberField
pub fn grouping(self, grouping: bool) -> NumberField
Whether thousands are separated without focus. On by default.
Sourcepub fn prefix(self, prefix: impl Into<String>) -> NumberField
pub fn prefix(self, prefix: impl Into<String>) -> NumberField
Text before the number without focus, such as a currency.
Sourcepub fn suffix(self, suffix: impl Into<String>) -> NumberField
pub fn suffix(self, suffix: impl Into<String>) -> NumberField
Text after the number without focus, such as %.
Sourcepub fn placeholder(self, text: impl Into<String>) -> NumberField
pub fn placeholder(self, text: impl Into<String>) -> NumberField
Muted text shown while the field is empty.
Sourcepub fn width(self, width: f32) -> NumberField
pub fn width(self, width: f32) -> NumberField
Fixed width in logical pixels; by default the field stretches.
Sourcepub fn label(self, label: impl Into<String>) -> NumberField
pub fn label(self, label: impl Into<String>) -> NumberField
The name screen readers announce. Inside a crate::FormField, its label is used instead.
Shows buttons that take a step away and add one.
Sourcepub fn disabled(self, disabled: bool) -> NumberField
pub fn disabled(self, disabled: bool) -> NumberField
Turns the field off: it fades, leaves the tab order and ignores input.
Sourcepub fn read_only(self, read_only: bool) -> NumberField
pub fn read_only(self, read_only: bool) -> NumberField
Shows the value without letting it change; it can still be focused and read.
Trait Implementations§
Source§impl Debug for NumberField
impl Debug for NumberField
Auto Trait Implementations§
impl !RefUnwindSafe for NumberField
impl !Send for NumberField
impl !Sync for NumberField
impl !UnwindSafe for NumberField
impl Freeze for NumberField
impl Unpin for NumberField
impl UnsafeUnpin for NumberField
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.