NumberField
数字编辑器,提供递增、递减和拖动调节部件。
正在加载交互演示…
func NumberFieldExample() *ui.Element {
value, setValue := ui.CreateSignal(8.0)
numberField := ui.NewNumberField(ui.NumberFieldRootProps{Value: func() *float64 {
current := value()
return ¤t
}, Min: 0, Max: 100, Step: 1, OnValueChange: func(next *float64, valid bool, _ *native.Event) {
if valid && next != nil {
setValue(*next)
}
}})
return numberField.Root().Children(
numberField.Decrement().Child("−"),
numberField.Input(),
numberField.Increment().Child("+"),
)
}#导入
从 github.com/egoist/quickgui/go/ui 导入 ui。
import (
"github.com/egoist/quickgui/go/native"
"github.com/egoist/quickgui/go/ui"
)#用法
func NumberFieldExample() *ui.Element {
value, setValue := ui.CreateSignal(8.0)
numberField := ui.NewNumberField(ui.NumberFieldRootProps{Value: func() *float64 {
current := value()
return ¤t
}, Min: 0, Max: 100, Step: 1, OnValueChange: func(next *float64, valid bool, _ *native.Event) {
if valid && next != nil {
setValue(*next)
}
}})
return numberField.Root().Children(
numberField.Decrement().Child("−"),
numberField.Input(),
numberField.Increment().Child("+"),
)
}#结构
numberField.RootnumberField.GroupnumberField.InputnumberField.IncrementnumberField.DecrementnumberField.ScrubAreanumberField.ScrubAreaCursor
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
NewNumberField
查看源码ui.NewNumberField(props ...NumberFieldRootProps) *NumberFieldComponentNewNumberField declares a NumberField instance. Optional props provide initial settings.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Valuefunc() *float64—
The current controlled value. Update application state from the change callback to accept a new value.
func() *float64查看源码DefaultValue*float64—
Initial value for uncontrolled state. Use Value when the application should own subsequent changes.
*float64查看源码Minany—
Maxany—
Stepany—
SmallStepany—
LargeStepany—
Precisionany—
SnapOnStep*bool—
AllowWheelScrub*bool—
ReadOnlybool—
Requiredbool—
ScrubDirectionstring—
ScrubSensitivityany—
OnValueChangefunc(*float64, bool, *native.Event)—
Reports an accepted value change. Use the callback payload to update controlled state.
func(*float64, bool, *native.Event)查看源码OnValueCommittedfunc(*float64, *native.Event)—
Callback for value committed. The signature below lists the event payload.
func(*float64, *native.Event)查看源码NumberField.Disabled
查看源码numberField.Disabled(value any) *NumberFieldComponentPrevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
NumberField.Value
查看源码numberField.Value(value any) *NumberFieldComponentThe current controlled value. Update application state from the change callback to accept a new value.
NumberField.DefaultValue
查看源码numberField.DefaultValue(value float64) *NumberFieldComponentInitial value for uncontrolled state. Use Value when the application should own subsequent changes.
NumberField.Min
查看源码numberField.Min(value any) *NumberFieldComponentLower bound of the accepted value.
NumberField.Max
查看源码numberField.Max(value any) *NumberFieldComponentUpper bound of the accepted value.
NumberField.Step
查看源码numberField.Step(value any) *NumberFieldComponentIncrement applied by pointer, keyboard, or step controls.
NumberField.SmallStep
查看源码numberField.SmallStep(value any) *NumberFieldComponentSmaller increment used by fine keyboard adjustment.
NumberField.LargeStep
查看源码numberField.LargeStep(value any) *NumberFieldComponentLarger increment used by accelerated keyboard adjustment.
NumberField.Precision
查看源码numberField.Precision(value any) *NumberFieldComponentNumber of fractional digits used for number formatting.
NumberField.SnapOnStep
查看源码numberField.SnapOnStep(value bool) *NumberFieldComponentSnaps the numeric value to a step boundary during adjustment.
NumberField.AllowWheelScrub
查看源码numberField.AllowWheelScrub(value bool) *NumberFieldComponentAllows wheel input to adjust the number field while its scrub interaction is active.
NumberField.ReadOnly
查看源码numberField.ReadOnly(value bool) *NumberFieldComponentPreserves the current value while keeping the control available for focus and inspection.
NumberField.Required
查看源码numberField.Required(value bool) *NumberFieldComponentMarks the control as required for validation and accessibility.
NumberField.ScrubDirection
查看源码numberField.ScrubDirection(value string) *NumberFieldComponentAxis used to translate scrub motion into value changes.
NumberField.ScrubSensitivity
查看源码numberField.ScrubSensitivity(value any) *NumberFieldComponentAmount of pointer motion required to change the numeric value.
NumberField.OnValueChange
查看源码numberField.OnValueChange(value func(*float64, bool, *native.Event)) *NumberFieldComponentReports an accepted value change. Use the callback payload to update controlled state.
NumberField.OnValueCommitted
查看源码numberField.OnValueCommitted(value func(*float64, *native.Event)) *NumberFieldComponentCallback for value committed. The signature below lists the event payload.
NumberField.Root
查看源码numberField.Root() *ElementConfigures root for this part. The declared type and source define the accepted value.
NumberField.Group
查看源码numberField.Group(options ...PartProps) *ElementNames this element as a group for descendant interaction-state styling.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.Input
查看源码numberField.Input(options ...NumberFieldInputProps) *ElementConfigures input for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Typestring—
Valueany—
The current controlled value. Update application state from the change callback to accept a new value.
any查看源码Placeholderstring—
Multilinebool—
OnInputfunc(*native.Event)—
Receives edits from the text control. Write the new text into the controlled value.
func(*native.Event)查看源码OnChangefunc(*native.Event)—
OnSubmitfunc(*native.Event)—
OnCommitfunc(CommitDetails, *native.Event)—
Reports one explicit commit boundary and its final value details.
func(CommitDetails, *native.Event)查看源码NumberField.Increment
查看源码numberField.Increment(options ...PartProps) *ElementConfigures increment for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.Decrement
查看源码numberField.Decrement(options ...PartProps) *ElementConfigures decrement for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.ScrubArea
查看源码numberField.ScrubArea(options ...PartProps) *ElementConfigures scrub area for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.ScrubAreaCursor
查看源码numberField.ScrubAreaCursor(options ...PartProps) *ElementConfigures scrub area cursor for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Styleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
any查看源码ChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildren查看源码Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
any查看源码Rolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
TabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64查看源码OnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)查看源码OnDoubleClickfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
OnMouseLeavefunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Element
查看源码part.Child(content).Style(style)Every part returns a fluent element. Strings, numbers, elements, and deferred child factories compose directly.
ChildChild(child any) *Element—
Child appends content and returns this element. Content can be an element, native node, scalar, accessor, or node-returning construction callback.
Child(child any) *Element查看源码ChildrenChildren(children ...any) *Element—
Children appends multiple children in order without replacing existing content. It also accepts []any, []*Element, and []*native.Node slices as arguments. Read the retained child nodes through element.Node.Children.
Children(children ...any) *Element查看源码StyleStyle(style StyleBuilder) *Element—
Style merges a reusable style. Scalar accessors retain independent native bindings.
Style(style StyleBuilder) *Element查看源码OnClickOnClick(handler func()) *Element—
RefRef(handler func(*native.Node)) *Element—
Ref exposes the native handle once at this point in the declaration chain.
Ref(handler func(*native.Node)) *Element查看源码