pub struct SearchState { /* private fields */ }Expand description
Retains editing, IME, result and focus state while the search view expands. The application performs asynchronous work and owns resulting navigation.
Implementations§
Source§impl SearchState
impl SearchState
Sourcepub fn new(
window: &mut Window,
cx: &mut Context<'_, SearchState>,
) -> SearchState
pub fn new( window: &mut Window, cx: &mut Context<'_, SearchState>, ) -> SearchState
Creates a collapsed search state with an owned TextFieldState editor.
Sourcepub fn with_editor(
input: &Entity<InputBaseState<InputMode>>,
window: &mut Window,
cx: &mut Context<'_, SearchState>,
) -> SearchState
pub fn with_editor( input: &Entity<InputBaseState<InputMode>>, window: &mut Window, cx: &mut Context<'_, SearchState>, ) -> SearchState
Uses an editor created for this window while retaining the search provider contract.
Sourcepub fn query(&self) -> &SharedString
pub fn query(&self) -> &SharedString
Returns the latest committed query text.
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Returns true when the target state is SearchValue::Expanded.
Sourcepub fn current_value(&self) -> SearchValue
pub fn current_value(&self) -> SearchValue
Returns the currently displayed state derived from Self::progress.
Sourcepub fn target_value(&self) -> SearchValue
pub fn target_value(&self) -> SearchValue
Returns the target endpoint (SearchValue::Collapsed or SearchValue::Expanded).
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Returns whether an expand or collapse transition is currently animating.
Sourcepub fn editor(&self) -> &Entity<InputBaseState<InputMode>>
pub fn editor(&self) -> &Entity<InputBaseState<InputMode>>
Returns the retained TextFieldState backing the search input.
Sourcepub fn input_focus(&self, cx: &App) -> FocusHandle
pub fn input_focus(&self, cx: &App) -> FocusHandle
Returns the stable focus handle of the expanded editor.
Sourcepub fn trigger_focus(&self) -> &FocusHandle
pub fn trigger_focus(&self) -> &FocusHandle
Returns the retained default focus handle of the search trigger.
Sourcepub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, SearchState>)
pub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, SearchState>)
Opens the view and focuses its editor immediately.
Sourcepub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, SearchState>)
pub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, SearchState>)
Dismisses the view and restores its entry focus immediately.
Sourcepub fn snap_to(
&mut self,
fraction: f32,
window: &mut Window,
cx: &mut Context<'_, SearchState>,
)
pub fn snap_to( &mut self, fraction: f32, window: &mut Window, cx: &mut Context<'_, SearchState>, )
Positions the presentation at a fraction from collapsed to expanded.
Sourcepub fn animate_to(
&mut self,
target: SearchValue,
duration: Duration,
window: &mut Window,
cx: &mut Context<'_, SearchState>,
)
pub fn animate_to( &mut self, target: SearchValue, duration: Duration, window: &mut Window, cx: &mut Context<'_, SearchState>, )
Animates to an endpoint. Retargeting uses the currently displayed fraction.
Sourcepub fn results(&self) -> Option<&SearchOutcome>
pub fn results(&self) -> Option<&SearchOutcome>
Returns the latest completed SearchOutcome, or None while idle or loading.
Sourcepub fn select_result(
&mut self,
result: SearchResult,
window: &mut Window,
cx: &mut Context<'_, SearchState>,
)
pub fn select_result( &mut self, result: SearchResult, window: &mut Window, cx: &mut Context<'_, SearchState>, )
Selects a caller-rendered result and dismisses using the retained focus path.
Sourcepub fn scroll_state(&self) -> &ListState
pub fn scroll_state(&self) -> &ListState
Returns the virtualized ListState used to scroll search results.
Sourcepub fn set_scroll_state(
&mut self,
scroll: &ListState,
cx: &mut Context<'_, SearchState>,
)
pub fn set_scroll_state( &mut self, scroll: &ListState, cx: &mut Context<'_, SearchState>, )
Uses a caller-owned virtual result viewport.
Sourcepub fn set_query(
&mut self,
query: impl Into<SharedString>,
window: &mut Window,
cx: &mut Context<'_, SearchState>,
)
pub fn set_query( &mut self, query: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, SearchState>, )
Synchronizes the query from the application. Query changes issue a request, followed by the normal completion path.
Sourcepub fn complete(
&mut self,
request: &SearchRequest,
outcome: SearchOutcome,
cx: &mut Context<'_, SearchState>,
) -> bool
pub fn complete( &mut self, request: &SearchRequest, outcome: SearchOutcome, cx: &mut Context<'_, SearchState>, ) -> bool
Accepts only the latest pending request. Returns false for superseded requests and duplicate completions.
Trait Implementations§
impl EventEmitter<SearchEvent> for SearchState
Auto Trait Implementations§
impl !RefUnwindSafe for SearchState
impl !Send for SearchState
impl !Sync for SearchState
impl !UnwindSafe for SearchState
impl Forget for SearchState
impl Freeze for SearchState
impl Move for SearchState
impl Unpin for SearchState
impl UnsafeUnpin for SearchState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more