parent
c30b4b0a1c
commit
8c08cce6ff
1 changed files with 36 additions and 27 deletions
|
|
@ -700,38 +700,47 @@ where
|
||||||
..
|
..
|
||||||
} = tree.state.downcast_mut::<Menu<T>>();
|
} = tree.state.downcast_mut::<Menu<T>>();
|
||||||
|
|
||||||
let bounds = layout.bounds();
|
|
||||||
|
|
||||||
self.state.sync_filtered_options(filtered_options);
|
self.state.sync_filtered_options(filtered_options);
|
||||||
|
|
||||||
let mut menu = menu::Menu::new(
|
if filtered_options.options.is_empty() {
|
||||||
menu,
|
None
|
||||||
&filtered_options.options,
|
} else {
|
||||||
hovered_option,
|
let bounds = layout.bounds();
|
||||||
|x| {
|
|
||||||
tree.children[0]
|
|
||||||
.state
|
|
||||||
.downcast_mut::<text_input::State<Renderer::Paragraph>>(
|
|
||||||
)
|
|
||||||
.unfocus();
|
|
||||||
|
|
||||||
(self.on_selected)(x)
|
let mut menu = menu::Menu::new(
|
||||||
},
|
menu,
|
||||||
self.on_option_hovered.as_deref(),
|
&filtered_options.options,
|
||||||
&self.menu_class,
|
hovered_option,
|
||||||
)
|
|x| {
|
||||||
.width(bounds.width)
|
tree.children[0]
|
||||||
.padding(self.padding);
|
.state
|
||||||
|
.downcast_mut::<text_input::State<Renderer::Paragraph>>(
|
||||||
|
)
|
||||||
|
.unfocus();
|
||||||
|
|
||||||
if let Some(font) = self.font {
|
(self.on_selected)(x)
|
||||||
menu = menu.font(font);
|
},
|
||||||
|
self.on_option_hovered.as_deref(),
|
||||||
|
&self.menu_class,
|
||||||
|
)
|
||||||
|
.width(bounds.width)
|
||||||
|
.padding(self.padding);
|
||||||
|
|
||||||
|
if let Some(font) = self.font {
|
||||||
|
menu = menu.font(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(size) = self.size {
|
||||||
|
menu = menu.text_size(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(
|
||||||
|
menu.overlay(
|
||||||
|
layout.position() + translation,
|
||||||
|
bounds.height,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(size) = self.size {
|
|
||||||
menu = menu.text_size(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(menu.overlay(layout.position() + translation, bounds.height))
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue