API 文档由 Go 源码生成,内容为英文。
type SingleSelectState struct {
Query text.Editor
Open bool
Active int
AllowCreate, MatchCaseInsensitive bool
// contains filtered or unexported fields
}
SingleSelectState owns one selection and a separate native search editor.
Selecting replaces the previous value and closes the list. Bind the native
text input to Query, and route option clicks and input keys to Choose and Key.
方法
Choices#
func (s *SingleSelectState) Choices() []SingleSelectChoice
Choices returns a read-only view until the next query or selection change.
It caches filtered rows, preserving selected and newly created values
even when the caller's options do not contain them. Exact labels and disabled
values cannot be bypassed through a duplicate create row.
Choose#
func (s *SingleSelectState) Choose(index int) bool
Choose always selects a single value, including when the row was selected.
Clear#
func (s *SingleSelectState) Clear()
CommitQuery#
func (s *SingleSelectState) CommitQuery() bool
CommitQuery confirms an exact existing value or a valid new value. A form can
call it on submit to preserve ordinary text-field save behavior.
Dismiss#
func (s *SingleSelectState) Dismiss()
Dismiss closes the list and drops the search text without changing the
value. Call it when focus or a press leaves the field.
Key#
func (s *SingleSelectState) Key(event ui.KeyEvent) ui.EventResult
Pointer#
func (s *SingleSelectState) Pointer(event ui.PointerEvent) ui.EventResult
SetOptions#
func (s *SingleSelectState) SetOptions(options []SingleSelectOption)
SetValidateCreate#
func (s *SingleSelectState) SetValidateCreate(validate func(string) bool)
SetValue#
func (s *SingleSelectState) SetValue(value string)
Value#
func (s *SingleSelectState) Value() string
Wheel#
func (s *SingleSelectState) Wheel(event ui.ScrollEvent) bool