Skip to content

Commit

Permalink
dropdown list docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Jun 3, 2024
1 parent b8a1787 commit 3a1fe2b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions fyrox-ui/src/dropdown_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UiNode>,
/// }
///
/// 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.
Expand Down

0 comments on commit 3a1fe2b

Please sign in to comment.