pub struct CommandTextInput {
pub trigger: Option<String>,
pub inline_search: bool,
pub color_focus: Vec4,
pub color_hover: Vec4,
/* private fields */
}
Expand description
TextInput
wrapper glued to a popup list of options that is shown when a
trigger character is typed.
Limitation: Selectable items are expected to be View
s.
Fields§
§trigger: Option<String>
The character that triggers the popup.
If not set, popup can’t be triggerd by keyboard.
Behavior is undefined if this string contains anything other than a single grapheme.
inline_search: bool
Handle search within the main text input instead of using a separate search input.
Note: Any kind of whitespace will terminate search.
color_focus: Vec4
Strong color to highlight the item that would be submitted if Return
is pressed.
color_hover: Vec4
Weak color to highlight the item that the pointer is hovering over.
Implementations§
Source§impl CommandTextInput
impl CommandTextInput
pub fn keyboard_focus_index(&self) -> Option<usize>
Sourcepub fn set_keyboard_focus_index(&mut self, idx: usize)
pub fn set_keyboard_focus_index(&mut self, idx: usize)
Sets the keyboard focus index for the list of selectable items Only updates the visual highlight state of the dropdown items
Sourcepub fn reset(&mut self, cx: &mut Cx)
pub fn reset(&mut self, cx: &mut Cx)
Clear all text and hide the popup going back to initial state.
Sourcepub fn clear_items(&mut self)
pub fn clear_items(&mut self)
Clears the list of items.
Normally called as response to should_build_items
.
Sourcepub fn add_item(&mut self, widget: WidgetRef)
pub fn add_item(&mut self, widget: WidgetRef)
Add a custom selectable item to the list.
Normally called after clearing the previous items.
Sourcepub fn add_unselectable_item(&mut self, widget: WidgetRef)
pub fn add_unselectable_item(&mut self, widget: WidgetRef)
Add a custom unselectable item to the list.
Ex: Headers, dividers, etc.
Normally called after clearing the previous items.
Sourcepub fn search_text(&self) -> String
pub fn search_text(&self) -> String
Get the current search query.
You probably want this for filtering purposes when updating the items.
Sourcepub fn item_selected(&self, actions: &Actions) -> Option<WidgetRef>
pub fn item_selected(&self, actions: &Actions) -> Option<WidgetRef>
Checks if any item has been selected in the given actions
and returns a reference to the selected item as a widget.
Sourcepub fn should_build_items(&self, actions: &Actions) -> bool
pub fn should_build_items(&self, actions: &Actions) -> bool
Returns true
if an action in the given actions
indicates that
the items to display need to be recomputed again.
For example, this returns true if the trigger character was typed, if the search filter changes, etc.
Sourcepub fn text_input_ref(&self) -> TextInputRef
pub fn text_input_ref(&self) -> TextInputRef
Returns a reference to the inner TextInput
widget.
Sourcepub fn search_input_ref(&self) -> TextInputRef
pub fn search_input_ref(&self) -> TextInputRef
Returns a reference to the inner TextInput
widget used for search.
Sourcepub fn request_text_input_focus(&mut self)
pub fn request_text_input_focus(&mut self)
Obtain focus in the main TextInput
widget as soon as possible.