[][src]Struct native_windows_gui::ComboBox

pub struct ComboBox<D: Display + Default> {
    pub handle: ControlHandle,
    // some fields omitted
}

A combo box consists of a list and a selection field. The list presents the options that a user can select, and the selection field displays the current selection.

Requires the combobox feature.

Builder parameters:

  • parent: Required. The combobox parent container.
  • size: The combobox size.
  • position: The combobox position.
  • enabled: If the combobox can be used by the user. It also has a grayed out look if disabled.
  • flags: A combination of the ComboBoxFlags values.
  • ex_flags: A combination of win32 window extended flags. Unlike flags, ex_flags must be used straight from winapi
  • font: The font used for the combobox text
  • collection: The default collection of the combobox
  • selected_index: The default selected index. None means no values are selected.
  • focus: The control receive focus after being created

Control events:

  • OnComboBoxClosed: When the combobox dropdown is closed
  • OnComboBoxDropdown: When the combobox dropdown is opened
  • OnComboxBoxSelection: When a new value in a combobox is choosen
  • MousePress(_): Generic mouse press events on the checkbox
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: Generic mouse wheel event
use native_windows_gui as nwg;
fn build_combobox(combo: &mut nwg::ComboBox<&'static str>, window: &nwg::Window) {
    let data = vec!["one", "two"];
    
    nwg::ComboBox::builder()
        .size((200, 300))
        .collection(data)
        .selected_index(Some(0))
        .parent(window)
        .build(combo);
}

Fields

handle: ControlHandle

Implementations

impl<D: Display + Default> ComboBox<D>[src]

pub fn builder<'a>() -> ComboBoxBuilder<'a, D>[src]

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 sort(&self)[src]

Sort the inner collection by the display value of it's items and update the view Internally this uses Vec.sort_unstable_by.

pub fn dropdown(&self, v: bool)[src]

Show or hide the dropdown of the combox

pub fn selection(&self) -> Option<usize>[src]

Return the index of the currencty selected item. Return None if no item is selected.

pub fn selection_string(&self) -> Option<String>[src]

Return the display value of the currenctly selected item 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 combobox. Does nothing if the index is out of bound If the value is None, remove the selected value

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 push(&self, item: D)[src]

Add a new item to the combobox. Sort the collection if the combobox 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 sync(&self)[src]

Update the visual of the control with the inner collection. This rebuild every item in the combobox 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 combobox. Return the old collection

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 combobox This call refcell.borrow under the hood. Be sure to drop the value before calling other combobox methods

pub fn collection_mut(&self) -> RefMut<'_, Vec<D>>[src]

Get mutable access to the inner collection of the combobox. 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 combobox 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 ComboBox<D>[src]

impl<D: Display + Default> Drop for ComboBox<D>[src]

impl<D: Display + Default> From<&'_ ComboBox<D>> for ControlHandle[src]

impl<D: Display + Default> PartialEq<ComboBox<D>> for ComboBox<D>[src]

impl<D: Display + Default> PartialEq<ComboBox<D>> for ControlHandle[src]

impl<D: Display + Default> PartialEq<ControlHandle> for ComboBox<D>[src]

Auto Trait Implementations

impl<D> !RefUnwindSafe for ComboBox<D>[src]

impl<D> !Send for ComboBox<D>[src]

impl<D> !Sync for ComboBox<D>[src]

impl<D> Unpin for ComboBox<D> where
    D: Unpin
[src]

impl<D> UnwindSafe for ComboBox<D> where
    D: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.