VirtualList

Struct VirtualList 

Source
pub struct VirtualList<T: 'static> {
    pub selection: RwSignal<Option<usize>>,
    /* private fields */
}

Fields§

§selection: RwSignal<Option<usize>>

Implementations§

Source§

impl<T> VirtualList<T>

Source

pub fn new<DF, I>(data_fn: DF) -> Self
where DF: Fn() -> I + 'static, I: VirtualVector<T>, T: Hash + Eq + IntoView + 'static,

Source

pub fn with_view<DF, I, V>( data_fn: DF, view_fn: impl Fn(T) -> V + 'static, ) -> Self
where DF: Fn() -> I + 'static, I: VirtualVector<T>, T: Hash + Eq + 'static, V: IntoView,

Source

pub fn with_key<DF, I, K>( data_fn: DF, key_fn: impl Fn(&T) -> K + 'static, ) -> Self
where DF: Fn() -> I + 'static, I: VirtualVector<T>, T: IntoView + 'static, K: Hash + Eq + 'static,

Source

pub fn full<DF, I, KF, K, VF, V>(data_fn: DF, key_fn: KF, view_fn: VF) -> Self
where DF: Fn() -> I + 'static, I: VirtualVector<T>, KF: Fn(&T) -> K + 'static, K: Eq + Hash + 'static, VF: Fn(usize, T) -> V + 'static, V: IntoView + 'static, T: 'static,

Source§

impl<T: 'static> VirtualList<T>

Source

pub fn selection(&self) -> RwSignal<Option<usize>>

Source

pub fn on_select(self, on_select: impl Fn(Option<usize>) + 'static) -> Self

Sets a callback function to be called whenever the selection changes in the virtual list.

The callback function receives an Option<usize> parameter representing the currently selected item index. When None, no item is selected. When Some(index), the item at that index is currently selected.

This is a convenience helper that creates a new effect internally. Calling this method multiple times will not override previous on_select calls - each call creates a separate effect that will all be triggered on selection changes. For more control, you can manually create effects using the selection signal returned by selection().

§Parameters
  • on_select - A function that takes Option<usize> and will be called on selection changes
§Returns

Returns self to allow method chaining.

§Example
use floem::prelude::*;

virtual_list(
    move || 1..=1000000,
    |item| *item,
    |index, item| format!("{index}: {item}")
)
.on_select(|selection| {
    match selection {
        Some(index) => println!("Selected item at index: {index}"),
        None => println!("No item selected"),
    }
});

Methods from Deref<Target = VirtualStack<(usize, T)>>§

Source

pub fn scroll_to_idx(&self, index: usize)

Scrolls to bring the item at the given index into view

Trait Implementations§

Source§

impl<T: 'static> Deref for VirtualList<T>

Source§

type Target = VirtualStack<(usize, T)>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &VirtualStack<(usize, T)>

Dereferences the value.
Source§

impl<T: 'static> DerefMut for VirtualList<T>

Source§

fn deref_mut(&mut self) -> &mut VirtualStack<(usize, T)>

Mutably dereferences the value.
Source§

impl<T: 'static> IntoView for VirtualList<T>

Source§

type V = VirtualStack<(usize, T)>

The final View type this converts to.
Source§

type Intermediate = VirtualStack<(usize, T)>

Intermediate type that has a ViewId before full view construction. Read more
Source§

fn into_intermediate(self) -> Self::Intermediate

Converts to the intermediate form which has a ViewId. Read more
Source§

fn into_view(self) -> Self::V

Converts the value into a View.
Source§

fn into_any(self) -> AnyView

Converts the value into a AnyView.

Auto Trait Implementations§

§

impl<T> Freeze for VirtualList<T>

§

impl<T> !RefUnwindSafe for VirtualList<T>

§

impl<T> !Send for VirtualList<T>

§

impl<T> !Sync for VirtualList<T>

§

impl<T> Unpin for VirtualList<T>

§

impl<T> !UnwindSafe for VirtualList<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ButtonExt for T
where T: IntoView + 'static,

Source§

fn button(self) -> Button

Create a Button from the parent.
Source§

impl<T> ClipExt for T
where T: IntoView + 'static,

Source§

fn clip(self) -> Clip

Wrap the view in a clip view.
Source§

impl<T> ContainerExt for T
where T: IntoView + 'static,

Source§

fn container(self) -> Container

Wrap the view in a container.
Source§

impl<T> Decorators for T
where T: IntoView,

Source§

fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::Intermediate

Alter the style of the view. Read more
Source§

fn debug_name(self, name: impl Into<String>) -> Self::Intermediate

Add a debug name to the view that will be shown in the inspector. Read more
Source§

fn debug_name_if<S: Into<String>>( self, apply: impl Fn() -> bool + 'static, name: impl Fn() -> S + 'static, ) -> Self::Intermediate

Conditionally add a debug name to the view that will be shown in the inspector. Read more
Source§

fn dragging_style( self, style: impl Fn(Style) -> Style + 'static, ) -> Self::Intermediate

The visual style to apply when the view is being dragged
Source§

fn class<C: StyleClass>(self, _class: C) -> Self::Intermediate

Add a style class to the view
Source§

fn class_if<C: StyleClass>( self, apply: impl Fn() -> bool + 'static, _class: C, ) -> Self::Intermediate

Conditionally add a style class to the view
Source§

fn remove_class<C: StyleClass>(self, _class: C) -> Self::Intermediate

Remove a style class from the view
Source§

fn keyboard_navigable(self) -> Self::Intermediate

👎Deprecated: Set this property using Style::focusable instead
Allows the element to be navigated to with the keyboard. Similar to setting tabindex=“0” in html.
Source§

fn disable_default_event( self, disable: impl Fn() -> (EventListener, bool) + 'static, ) -> Self::Intermediate

Dynamically controls whether the default view behavior for an event should be disabled. When disable is true, children will still see the event, but the view event function will not be called nor the event listeners on the view. Read more
Source§

fn draggable(self) -> Self::Intermediate

👎Deprecated: use Style::draggable directly instead
Mark the view as draggable
Source§

fn disabled( self, disabled_fn: impl Fn() -> bool + 'static, ) -> Self::Intermediate

👎Deprecated: use Style::set_disabled directly instead
Mark the view as disabled Read more
Source§

fn on_event( self, listener: EventListener, action: impl FnMut(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate

Add an event handler for the given EventListener.
Source§

fn on_key_down( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an handler for pressing down a specific key. Read more
Source§

fn on_key_up( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an handler for a specific key being released. Read more
Source§

fn on_event_cont( self, listener: EventListener, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for the given EventListener. This event will be handled with the given handler and the event will continue propagating.
Source§

fn on_event_stop( self, listener: EventListener, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for the given EventListener. This event will be handled with the given handler and the event will stop propagating.
Source§

fn on_click( self, action: impl FnMut(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::Click.
Source§

fn on_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::Intermediate

Add an event handler for EventListener::Click. This event will be handled with the given handler and the event will continue propagating.
Source§

fn on_click_stop( self, action: impl FnMut(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::Click. This event will be handled with the given handler and the event will stop propagating.
Source§

fn action(self, action: impl FnMut() + 'static) -> Self::Intermediate

Attach action executed on button click or Enter or Space Key.
Source§

fn on_double_click( self, action: impl Fn(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::DoubleClick
Source§

fn on_double_click_cont( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::DoubleClick. This event will be handled with the given handler and the event will continue propagating.
Source§

fn on_double_click_stop( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::DoubleClick. This event will be handled with the given handler and the event will stop propagating.
Source§

fn on_secondary_click( self, action: impl Fn(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::SecondaryClick. This is most often the “Right” click.
Source§

fn on_secondary_click_cont( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::SecondaryClick. This is most often the “Right” click. This event will be handled with the given handler and the event will continue propagating.
Source§

fn on_secondary_click_stop( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate

Add an event handler for EventListener::SecondaryClick. This is most often the “Right” click. This event will be handled with the given handler and the event will stop propagating.
Source§

fn on_resize(self, action: impl Fn(Rect) + 'static) -> Self::Intermediate

Adds an event handler for resize events for this view. Read more
Source§

fn on_move(self, action: impl Fn(Point) + 'static) -> Self::Intermediate

Adds an event handler for move events for this view. Read more
Source§

fn on_cleanup(self, action: impl Fn() + 'static) -> Self::Intermediate

Adds an event handler for cleanup events for this view. Read more
Source§

fn animation( self, animation: impl Fn(Animation) -> Animation + 'static, ) -> Self::Intermediate

Add an animation to the view. Read more
Source§

fn clear_focus(self, when: impl Fn() + 'static) -> Self::Intermediate

Clear the focus from the window. Read more
Source§

fn request_focus(self, when: impl Fn() + 'static) -> Self::Intermediate

Request that this view gets the focus for the window. Read more
Source§

fn window_scale( self, scale_fn: impl Fn() -> f64 + 'static, ) -> Self::Intermediate

Set the window scale factor. Read more
Source§

fn window_title( self, title_fn: impl Fn() -> String + 'static, ) -> Self::Intermediate

Set the window title. Read more
Source§

fn window_menu(self, menu_fn: impl Fn() -> Menu + 'static) -> Self::Intermediate

Set the system window menu Read more
Source§

fn context_menu(self, menu: impl Fn() -> Menu + 'static) -> Self::Intermediate

Adds a secondary-click context menu to the view, which opens at the mouse position. Read more
Source§

fn popout_menu(self, menu: impl Fn() -> Menu + 'static) -> Self::Intermediate

Adds a primary-click context menu, which opens below the view. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ScrollExt for T
where T: IntoView + 'static,

Source§

fn scroll(self) -> Scroll

Wrap the view in a scroll view.
Source§

impl<T> TooltipExt for T
where T: IntoView + 'static,

Source§

fn tooltip<V>(self, tip: impl Fn() -> V + 'static) -> Tooltip
where V: IntoView + 'static,

Adds a tooltip to the view. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,