diff options
author | crupest <crupest@outlook.com> | 2022-02-15 21:42:12 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-15 21:42:12 +0800 |
commit | 43a297f30c03180427db435bb25a1a4b51ea847a (patch) | |
tree | 54843de2695fc145d35845b4d243d72c61877b55 /src/ui/components/Select.cpp | |
parent | 24aaa8fbc5da8370506402facdb8ccaf563454e5 (diff) | |
download | cru-43a297f30c03180427db435bb25a1a4b51ea847a.tar.gz cru-43a297f30c03180427db435bb25a1a4b51ea847a.tar.bz2 cru-43a297f30c03180427db435bb25a1a4b51ea847a.zip |
...
Diffstat (limited to 'src/ui/components/Select.cpp')
-rw-r--r-- | src/ui/components/Select.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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<String> items) { + items_ = items; popup_menu_.GetMenu()->ClearItems(); for (Index i = 0; i < items.size(); i++) { popup_menu_.GetMenu()->AddTextItem(std::move(items[i]), |