dropdown: Support change options for the dropdown (#824)
This commit is contained in:
parent
dd3b8b1f3d
commit
a5e5fc52b4
2 changed files with 20 additions and 7 deletions
|
|
@ -138,21 +138,24 @@ impl DropdownStory {
|
|||
.title_prefix("UI: ")
|
||||
}),
|
||||
simple_dropdown2: cx.new(|cx| {
|
||||
Dropdown::new(
|
||||
"string-list2",
|
||||
let mut dropdown =
|
||||
Dropdown::new("string-list2", SearchableVec::new(vec![]), None, window, cx)
|
||||
.small()
|
||||
.placeholder("Language")
|
||||
.title_prefix("Language: ");
|
||||
|
||||
dropdown.set_items(
|
||||
SearchableVec::new(vec![
|
||||
"Rust".into(),
|
||||
"Go".into(),
|
||||
"C++".into(),
|
||||
"JavaScript".into(),
|
||||
]),
|
||||
None,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
.small()
|
||||
.placeholder("Language")
|
||||
.title_prefix("Language: ")
|
||||
);
|
||||
|
||||
dropdown
|
||||
}),
|
||||
simple_dropdown3: cx.new(|cx| {
|
||||
Dropdown::new("string-list3", Vec::<SharedString>::new(), None, window, cx)
|
||||
|
|
|
|||
|
|
@ -600,6 +600,16 @@ where
|
|||
})
|
||||
.child(title)
|
||||
}
|
||||
|
||||
/// Set the items for the dropdown.
|
||||
pub fn set_items(&mut self, items: D, _: &mut Window, cx: &mut Context<Self>)
|
||||
where
|
||||
D: DropdownDelegate + 'static,
|
||||
{
|
||||
self.list.update(cx, |list, _| {
|
||||
list.delegate_mut().delegate = items;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> Sizable for Dropdown<D>
|
||||
|
|
|
|||
Loading…
Reference in a new issue