pub trait ListDelegate: Sized + 'static {
type Item: Selectable + IntoElement;
Show 16 methods
// Required methods
fn items_count(&self, section: usize, cx: &App) -> usize;
fn render_item(
&mut self,
ix: IndexPath,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Option<Self::Item>;
fn set_selected_index(
&mut self,
ix: Option<IndexPath>,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
);
// Provided methods
fn perform_search(
&mut self,
query: &str,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Task<()> { ... }
fn sections_count(&self, cx: &App) -> usize { ... }
fn render_section_header(
&mut self,
section: usize,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Option<impl IntoElement> { ... }
fn render_section_footer(
&mut self,
section: usize,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Option<impl IntoElement> { ... }
fn render_empty(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> impl IntoElement { ... }
fn render_initial(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Option<AnyElement> { ... }
fn loading(&self, cx: &App) -> bool { ... }
fn render_loading(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> impl IntoElement { ... }
fn confirm(
&mut self,
secondary: bool,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) { ... }
fn cancel(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) { ... }
fn is_eof(&self, cx: &App) -> bool { ... }
fn load_more_threshold(&self) -> usize { ... }
fn load_more(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) { ... }
}Expand description
A delegate for the List.
Required Associated Types§
type Item: Selectable + IntoElement
Required Methods§
Sourcefn items_count(&self, section: usize, cx: &App) -> usize
fn items_count(&self, section: usize, cx: &App) -> usize
Return the number of items in the section at the given index.
Provided Methods§
Sourcefn perform_search(
&mut self,
query: &str,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Task<()>
fn perform_search( &mut self, query: &str, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, ) -> Task<()>
When Query Input change, this method will be called. You can perform search here.
Sourcefn sections_count(&self, cx: &App) -> usize
fn sections_count(&self, cx: &App) -> usize
Return the number of sections in the list, default is 1.
Sourcefn render_section_header(
&mut self,
section: usize,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Option<impl IntoElement>
fn render_section_header( &mut self, section: usize, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, ) -> Option<impl IntoElement>
Render the section header at the given index, default is None.
NOTE: Every header should have same height.
Render the section footer at the given index, default is None.
NOTE: Every footer should have same height.
Sourcefn render_empty(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> impl IntoElement
fn render_empty( &mut self, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, ) -> impl IntoElement
Return a Element to show when list is empty.
Sourcefn render_initial(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> Option<AnyElement>
fn render_initial( &mut self, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, ) -> Option<AnyElement>
Returns Some(AnyElement) to render the initial state of the list.
This can be used to show a view for the list before the user has interacted with it.
For example: The last search results, or the last selected item.
Default is None, that means no initial state.
Sourcefn render_loading(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
) -> impl IntoElement
fn render_loading( &mut self, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, ) -> impl IntoElement
Returns a Element to show when loading, default is built-in Skeleton loading view.
Sourcefn confirm(
&mut self,
secondary: bool,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
)
fn confirm( &mut self, secondary: bool, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, )
Set the confirm and give the selected index, this is means user have clicked the item or pressed Enter.
This will always to set_selected_index before confirm.
Sourcefn cancel(&mut self, window: &mut Window, cx: &mut Context<'_, ListState<Self>>)
fn cancel(&mut self, window: &mut Window, cx: &mut Context<'_, ListState<Self>>)
Cancel the selection, e.g.: Pressed ESC.
Sourcefn is_eof(&self, cx: &App) -> bool
fn is_eof(&self, cx: &App) -> bool
Return true to enable load more data when scrolling to the bottom.
Default: true
Sourcefn load_more_threshold(&self) -> usize
fn load_more_threshold(&self) -> usize
Returns a threshold value (n entities), of course,
when scrolling to the bottom, the remaining number of rows
triggers load_more.
This should smaller than the total number of first load rows.
Default: 20 entities (section header, footer and row)
Sourcefn load_more(
&mut self,
window: &mut Window,
cx: &mut Context<'_, ListState<Self>>,
)
fn load_more( &mut self, window: &mut Window, cx: &mut Context<'_, ListState<Self>>, )
Load more data when the table is scrolled to the bottom.
This will performed in a background task.
This is always called when the table is near the bottom, so you must check if there is more data to load or lock the loading state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.