From 43a297f30c03180427db435bb25a1a4b51ea847a Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 15 Feb 2022 21:42:12 +0800 Subject: ... --- src/ui/components/Select.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ui/components') diff --git a/src/ui/components/Select.cpp b/src/ui/components/Select.cpp index 9f9fbfae..6a316717 100644 --- a/src/ui/components/Select.cpp +++ b/src/ui/components/Select.cpp @@ -4,7 +4,11 @@ namespace cru::ui::components { Select::Select() { button_.SetChild(&button_text_); button_.ClickEvent()->AddHandler([this](const helper::ClickEventArgs& args) { - popup_menu_.SetPosition(args.GetDownPoint()); + auto left_bottom = + button_.GetContainerRenderObject()->GetTotalOffset() + + Point{0, button_.GetContainerRenderObject()->GetSize().height}; + popup_menu_.SetPosition(args.GetDownPointOfScreen() - args.GetDownPoint() + + left_bottom); popup_menu_.Show(); }); } @@ -12,6 +16,7 @@ Select::Select() { Select::~Select() { button_.RemoveFromParent(); } void Select::SetItems(std::vector items) { + items_ = items; popup_menu_.GetMenu()->ClearItems(); for (Index i = 0; i < items.size(); i++) { popup_menu_.GetMenu()->AddTextItem(std::move(items[i]), -- cgit v1.2.3