[−][src]Struct native_windows_gui::ListBox
A list box is a control window that contains a simple list of items from which the user can choose.
Requires the list-box
feature.
Builder parameters:
parent
: Required. The listbox parent container.size
: The listbox size.position
: The listbox position.enabled
: If the listbox can be used by the user. It also has a grayed out look if disabled.focus
: The control receive focus after being createdflags
: A combination of the ListBoxFlags values.font
: The font used for the listbox textcollection
: The default collections of the listboxselected_index
: The default selected index in the listbox collectionmulti_selection
: The collections of indices to set as selected in a multi selection listbox
Control events:
OnListBoxSelect
: When the current listbox selection is changedOnListBoxDoubleClick
: When a listbox item is clicked twice rapidlyMousePress(_)
: Generic mouse press events on the listboxOnMouseMove
: Generic mouse mouse eventOnMouseWheel
: Generic mouse wheel event
use native_windows_gui as nwg; fn build_listbox(listb: &mut nwg::ListBox<&'static str>, window: &nwg::Window, font: &nwg::Font) { nwg::ListBox::builder() .flags(nwg::ListBoxFlags::VISIBLE | nwg::ListBoxFlags::MULTI_SELECT) .collection(vec!["Hello", "World", "!!!!"]) .multi_selection(vec![0, 1, 2]) .font(Some(font)) .parent(window) .build(listb); }
Fields
handle: ControlHandle
Implementations
impl<D: Display + Default> ListBox<D>
[src]
pub fn builder<'a>() -> ListBoxBuilder<'a, D>
[src]
pub fn push(&self, item: D)
[src]
Add a new item to the listbox. Sort the collection if the listbox is sorted.
pub fn insert(&self, index: usize, item: D)
[src]
Insert an item in the collection and the control.
SPECIAL behaviour! If index is std::usize::MAX
, the item is added at the end of the collection.
The method will still panic if index > len
with every other values.
pub fn remove(&self, index: usize) -> D
[src]
Remove the item at the selected index and returns it. Panic of the index is out of bounds
pub fn selection(&self) -> Option<usize>
[src]
Return the index of the currencty selected item for single value list box.
Return None
if no item is selected.
pub fn multi_selection_len(&self) -> usize
[src]
Return the number of selected item in the list box Returns 0 for single select list box
pub fn multi_selection(&self) -> Vec<usize>
[src]
Return a list index Returns an empty vector for single select list box.
pub fn selection_string(&self) -> Option<String>
[src]
Return the display value of the currenctly selected item for single value
Return None
if no item is selected. This reads the visual value.
pub fn set_selection(&self, index: Option<usize>)
[src]
Set the currently selected item in the list box for single value list box. Does nothing if the index is out of bound If the value is None, remove the selected value
pub fn multi_add_selection(&self, index: usize)
[src]
Select the item as index index
in a multi item list box
pub fn multi_remove_selection(&self, index: usize)
[src]
Unselect the item as index index
in a multi item list box
pub fn unselect_all(&self)
[src]
Unselect every item in the list box
pub fn select_all(&self)
[src]
Select every item in the list box
pub fn multi_select_range(&self, range: Range<usize>)
[src]
Select a range of items in a multi list box
pub fn multi_unselect_range(&self, range: Range<usize>)
[src]
Unselect a range of items in a multi list box
pub fn set_selection_string(&self, value: &str) -> Option<usize>
[src]
Search an item that begins by the value and select the first one found. The search is not case sensitive, so this string can contain any combination of uppercase and lowercase letters. Return the index of the selected string or None if the search was not successful
pub fn selected(&self, index: usize) -> bool
[src]
Check if the item at index
is selected by the user
Return false
if the index is out of range.
pub fn sync(&self)
[src]
Update the visual of the control with the inner collection. This rebuild every item in the list box and can take some time on big collections.
pub fn set_collection(&self, col: Vec<D>) -> Vec<D>
[src]
Set the item collection of the list box. Return the old collection
pub fn clear(&self)
[src]
Clears the control and free the underlying collection. Same as set_collection(Vec::new())
pub fn len(&self) -> usize
[src]
Return the number of items in the control. NOT the inner rust collection
pub fn font(&self) -> Option<Font>
[src]
Return the font of the control
pub fn set_font(&self, font: Option<&Font>)
[src]
Set the font of the control
pub fn focus(&self) -> bool
[src]
Return true if the control currently has the keyboard focus
pub fn set_focus(&self)
[src]
Set the keyboard focus on the button.
pub fn enabled(&self) -> bool
[src]
Return true if the control user can interact with the control, return false otherwise
pub fn set_enabled(&self, v: bool)
[src]
Enable or disable the control
pub fn visible(&self) -> bool
[src]
Return true if the control is visible to the user. Will return true even if the control is outside of the parent client view (ex: at the position (10000, 10000))
pub fn set_visible(&self, v: bool)
[src]
Show or hide the control to the user
pub fn size(&self) -> (u32, u32)
[src]
Return the size of the button in the parent window
pub fn set_size(&self, x: u32, y: u32)
[src]
Set the size of the button in the parent window
pub fn position(&self) -> (i32, i32)
[src]
Return the position of the button in the parent window
pub fn set_position(&self, x: i32, y: i32)
[src]
Set the position of the button in the parent window
pub fn collection(&self) -> Ref<'_, Vec<D>>
[src]
Get read-only access to the inner collection of the list box This call refcell.borrow under the hood. Be sure to drop the value before calling other list box methods
pub fn collection_mut(&self) -> RefMut<'_, Vec<D>>
[src]
Get mutable access to the inner collection of the list box. Does not update the visual
control. Call sync
to update the view. This call refcell.borrow_mut under the hood.
Be sure to drop the value before calling other list box methods
pub fn class_name(&self) -> &'static str
[src]
Winapi class name used during control creation
pub fn flags(&self) -> u32
[src]
Winapi base flags used during window creation
pub fn forced_flags(&self) -> u32
[src]
Winapi flags required by the control
Trait Implementations
impl<D: Default + Display> Default for ListBox<D>
[src]
impl<D: Display + Default> Drop for ListBox<D>
[src]
impl<D: Display + Default, '_> From<&'_ ListBox<D>> for ControlHandle
[src]
impl<D: Display + Default> PartialEq<ControlHandle> for ListBox<D>
[src]
fn eq(&self, other: &ControlHandle) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<D: Display + Default> PartialEq<ListBox<D>> for ListBox<D>
[src]
impl<D: Display + Default> PartialEq<ListBox<D>> for ControlHandle
[src]
Auto Trait Implementations
impl<D> !RefUnwindSafe for ListBox<D>
impl<D> !Send for ListBox<D>
impl<D> !Sync for ListBox<D>
impl<D> Unpin for ListBox<D> where
D: Unpin,
D: Unpin,
impl<D> UnwindSafe for ListBox<D> where
D: UnwindSafe,
D: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,