From 3a1fe2b5fc83c710048f7500b8449952cd0fb82c Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Mon, 3 Jun 2024 11:22:20 +0300 Subject: [PATCH] dropdown list docs improvements --- fyrox-ui/src/dropdown_list.rs | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/fyrox-ui/src/dropdown_list.rs b/fyrox-ui/src/dropdown_list.rs index 3c476db42..75b3bceda 100644 --- a/fyrox-ui/src/dropdown_list.rs +++ b/fyrox-ui/src/dropdown_list.rs @@ -121,7 +121,49 @@ impl DropdownListMessage { /// } /// ``` /// +/// ## Selection /// +/// Dropdown list supports two kinds of selection - `None` or `Some(index)`. To catch a moment when +/// selection changes, use the following code: +/// +/// ```rust +/// use fyrox_ui::{ +/// core::pool::Handle, +/// dropdown_list::DropdownListMessage, +/// message::{MessageDirection, UiMessage}, +/// UiNode, +/// }; +/// +/// struct Foo { +/// dropdown_list: Handle, +/// } +/// +/// impl Foo { +/// fn on_ui_message(&mut self, message: &UiMessage) { +/// if let Some(DropdownListMessage::SelectionChanged(new_selection)) = message.data() { +/// if message.destination() == self.dropdown_list +/// && message.direction() == MessageDirection::FromWidget +/// { +/// // Do something. +/// dbg!(new_selection); +/// } +/// } +/// } +/// } +/// ``` +/// +/// To change selection of a dropdown list, send [`DropdownListMessage::SelectionChanged`] message +/// to it. +/// +/// ## Items +/// +/// To change current items of a dropdown list, create the items first and then send them to the +/// dropdown list using [`DropdownListMessage::Items`] message. +/// +/// ## Opening and Closing +/// +/// A dropdown list could be opened and closed manually using [`DropdownListMessage::Open`] and +/// [`DropdownListMessage::Close`] messages. #[derive(Default, Clone, Debug, Visit, Reflect, ComponentProvider)] pub struct DropdownList { /// Base widget of the dropdown list.