diff options
author | crupest <crupest@outlook.com> | 2022-03-02 22:07:33 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-02 22:07:33 +0800 |
commit | 57353bd3acd97957cb5f970016fec52977cc6e95 (patch) | |
tree | 6e47a50f33466f7bcdce7c7aa9bf15b82fe4a58a /src/ui/components/PopupButton.cpp | |
parent | 7adfe813c23d20abe936aa0624fd68e0112717b3 (diff) | |
download | cru-57353bd3acd97957cb5f970016fec52977cc6e95.tar.gz cru-57353bd3acd97957cb5f970016fec52977cc6e95.tar.bz2 cru-57353bd3acd97957cb5f970016fec52977cc6e95.zip |
...
Diffstat (limited to 'src/ui/components/PopupButton.cpp')
-rw-r--r-- | src/ui/components/PopupButton.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ui/components/PopupButton.cpp b/src/ui/components/PopupButton.cpp index f09bf2d1..41e0ad6c 100644 --- a/src/ui/components/PopupButton.cpp +++ b/src/ui/components/PopupButton.cpp @@ -21,4 +21,21 @@ void PopupMenuTextButton::SetMenuItems(std::vector<String> items) { std::move(items[i]), [this, i] { menu_item_selected_event_.Raise(i); }); } } + +PopupMenuIconButton::PopupMenuIconButton() : popup_menu_(&button_) { + button_.ClickEvent()->AddHandler([this](const helper::ClickEventArgs& args) { + popup_menu_.SetPosition(args.GetDownPointOfScreen()); + popup_menu_.Show(); + }); +} + +PopupMenuIconButton::~PopupMenuIconButton() {} + +void PopupMenuIconButton::SetMenuItems(std::vector<String> items) { + popup_menu_.GetMenu()->ClearItems(); + for (Index i = 0; i < items.size(); i++) { + popup_menu_.GetMenu()->AddTextItem( + std::move(items[i]), [this, i] { menu_item_selected_event_.Raise(i); }); + } +} } // namespace cru::ui::components |