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) -> Self
pub fn on_leave(self, handler: impl Fn() + 'static) -> Self
Called when the keyboard goes elsewhere after being here.
Sourcepub fn new(value: Binding<Option<f64>>) -> Self
pub fn new(value: Binding<Option<f64>>) -> Self
A field bound to value, unbounded, with no decimals; None is empty.
Sourcepub fn money(cents: Binding<Option<i64>>, prefix: impl Into<String>) -> Self
pub fn money(cents: Binding<Option<i64>>, prefix: impl Into<String>) -> Self
A field for money held as a whole number of cents: exact, two decimals,
showing prefix, such as "R$ ".
Sourcepub fn step(self, step: f64) -> Self
pub fn step(self, step: f64) -> Self
How much Up, Down and the buttons change the value. 1 by default.
Sourcepub fn decimals(self, decimals: usize) -> Self
pub fn decimals(self, decimals: usize) -> Self
Digits shown after the decimal separator without focus. 0 by default.
Sourcepub fn grouping(self, grouping: bool) -> Self
pub fn grouping(self, grouping: bool) -> Self
Whether thousands are separated without focus. On by default.
Sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Text before the number without focus, such as a currency.
Sourcepub fn suffix(self, suffix: impl Into<String>) -> Self
pub fn suffix(self, suffix: impl Into<String>) -> Self
Text after the number without focus, such as %.
Sourcepub fn placeholder(self, text: impl Into<String>) -> Self
pub fn placeholder(self, text: impl Into<String>) -> Self
Muted text shown while the field is empty.
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Fixed width in logical pixels; by default the field stretches.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
The name screen readers announce. Inside a crate::FormField, its label is used instead.
Shows buttons that take a step away and add one.
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§
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<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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.