mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
Make dropdowns start with the current value when you open them
This commit is contained in:
parent
1fb1253e97
commit
4ee50de58d
@ -56,7 +56,6 @@ impl<T: 'static + PartialEq + Clone> Dropdown<T> {
|
||||
|
||||
impl<T: 'static + Clone> Dropdown<T> {
|
||||
fn open_menu(&mut self, ctx: &mut EventCtx) {
|
||||
// TODO set current idx in menu
|
||||
let mut menu = Menu::new(
|
||||
ctx,
|
||||
self.choices
|
||||
@ -65,6 +64,7 @@ impl<T: 'static + Clone> Dropdown<T> {
|
||||
.map(|(idx, c)| c.with_value(idx))
|
||||
.collect(),
|
||||
);
|
||||
menu.set_current(self.current_idx);
|
||||
let y1_below = self.btn.top_left.y + self.btn.dims.height + 15.0;
|
||||
|
||||
menu.set_pos(ScreenPt::new(
|
||||
|
@ -35,6 +35,10 @@ impl<T: 'static> Menu<T> {
|
||||
self.choices.remove(self.current_idx).data
|
||||
}
|
||||
|
||||
pub fn set_current(&mut self, idx: usize) {
|
||||
self.current_idx = idx;
|
||||
}
|
||||
|
||||
fn calculate_txt(&self, style: &Style) -> Text {
|
||||
let mut txt = Text::new();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user