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ソースを見る