From f655d9b9674fe5a705e26b8797231d93a117395b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 18 Apr 2020 20:44:14 +0200 Subject: Position `Menu` layer based on available space --- native/src/widget/combo_box.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/combo_box.rs b/native/src/widget/combo_box.rs index 1b04a9a8..0f249282 100644 --- a/native/src/widget/combo_box.rs +++ b/native/src/widget/combo_box.rs @@ -1,7 +1,7 @@ use crate::{ layer::{self, menu}, layout, mouse, scrollable, text, Clipboard, Element, Event, Hasher, Layout, - Length, Overlay, Point, Rectangle, Size, Vector, Widget, + Length, Overlay, Point, Rectangle, Size, Widget, }; use std::borrow::Cow; @@ -210,14 +210,16 @@ where if is_open { if let Some(Internal { menu, on_selected }) = self.internal.take() { + let bounds = layout.bounds(); + Some(Overlay::new( - layout.position() - + Vector::new(0.0, layout.bounds().height), + layout.position(), Box::new(layer::Menu::new( menu, self.options.clone(), on_selected, - layout.bounds().width.round() as u16, + bounds.width.round() as u16, + bounds.height, self.text_size.unwrap_or(20), self.padding, )), -- cgit