NumberField
数字编辑器,提供递增、递减和拖动调节部件。
正在加载交互演示…
let field = NumberField::new("amount", &state);
field.root().child(field.input_with(text_input(state.text())))#导入
从 quickgui 导入 NumberField。
use quickgui::*;#用法
let field = NumberField::new("amount", &state);
field.root().child(field.input_with(text_input(state.text())))#结构
NumberField::rootNumberField::groupNumberField::inputNumberField::incrementNumberField::decrementNumberField::scrub_areaNumberField::scrub_area_cursor
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
NumberField
查看源码pub fn new(root_id: impl Into<ElementId>) -> Selfroot_idpub const fn root_id(self) -> ElementId—
input_idpub fn input_id(self) -> ElementId—
increment_idpub fn increment_id(self) -> ElementId—
decrement_idpub fn decrement_id(self) -> ElementId—
group_idpub fn group_id(self) -> ElementId—
Stable identity of the group that wraps the steppers and the input.
pub fn group_id(self) -> ElementId查看源码scrub_area_idpub fn scrub_area_id(self) -> ElementId—
scrub_area_cursor_idpub fn scrub_area_cursor_id(self) -> ElementId—
Stable identity of the caller-owned cursor shown while scrubbing.
pub fn scrub_area_cursor_id(self) -> ElementId查看源码NumberField::root_with
查看源码pub fn root_with(self, root: Element) -> ElementDecorate an application-owned root without adding layout or appearance.
NumberField::root
查看源码pub fn root(self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
NumberField::input_with
查看源码pub fn input_with(self, state: &NumberFieldState, input: Element) -> ElementDecorate the application-owned controlled input. Pass a [`crate::text_input`] built from [`NumberFieldState::text`] with the caller's own [`crate::Element::on_input`] listener. QuickGUI adds the spin-button semantics: the committed numeric value, the field's bounds and step, and invalid state.
NumberField::input
查看源码pub fn input(self, state: &NumberFieldState) -> ElementCreate the unstyled input part. Use [`Self::input_with`] to supply an existing element.
NumberField::increment_with
查看源码pub fn increment_with(self, state: &NumberFieldState, increment: Element) -> ElementDecorate the application-owned increment button. Steppers stay out of the Tab sequence because the input already answers arrow keys, which matches native desktop spin buttons.
NumberField::increment
查看源码pub fn increment(self, state: &NumberFieldState) -> ElementCreate the unstyled increment part. Use [`Self::increment_with`] to supply an existing element.
NumberField::decrement_with
查看源码pub fn decrement_with(self, state: &NumberFieldState, decrement: Element) -> ElementDecorate the application-owned decrement button.
NumberField::decrement
查看源码pub fn decrement(self, state: &NumberFieldState) -> ElementCreate the unstyled decrement part. Use [`Self::decrement_with`] to supply an existing element.
NumberField::group_with
查看源码pub fn group_with(self, group: Element) -> ElementDecorate the caller-owned group that wraps the decrement, input, and increment parts. Base UI's Group keeps the three controls one addressable unit; QuickGUI supplies the stable identity and the Group role and adds no layout, so the application still chooses the row, the order, and the spacing.
NumberField::group
查看源码pub fn group(self) -> ElementCreate the unstyled group part. Use [`Self::group_with`] to supply an existing element.
NumberField::scrub_area_with
查看源码pub fn scrub_area_with(self, state: &NumberFieldState, scrub_area: Element) -> ElementDecorate the caller-owned area a pointer drag scrubs the value over. Attach a [`crate::ViewContext::pointer_listener`] registered for [`Self::scrub_area_id`] and forward the event to [`NumberFieldState::apply_scrub`]. QuickGUI supplies the identity, the axis-appropriate resize cursor, drag exclusion, and text-selection suppression; the area is hidden from assistive technology because the input already carries the spin-button semantics.
NumberField::scrub_area
查看源码pub fn scrub_area(self, state: &NumberFieldState) -> ElementCreate the unstyled scrub area part. Use [`Self::scrub_area_with`] to supply an existing element.
NumberField::scrub_area_cursor_with
查看源码pub fn scrub_area_cursor_with(self, cursor: Element) -> ElementDecorate the caller-owned cursor a scrub area shows while it is being dragged. Mount it only while [`NumberFieldState::is_scrubbing`] is true and place it from [`NumberFieldState::scrub_position`]; QuickGUI supplies the identity and keeps the decoration out of the accessible name and out of hit testing.
NumberField::scrub_area_cursor
查看源码pub fn scrub_area_cursor(self) -> ElementCreate the unstyled scrub area cursor part. Use [`Self::scrub_area_cursor_with`] to supply an existing element.
