From 93c67bc8684c3daaf7c0e8bf6eb7219f26cbcbdb Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 12 Dec 2020 21:57:39 -0500 Subject: menu stuff (fix #4) --- util.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'util.hpp') diff --git a/util.hpp b/util.hpp index 0a93343..9cca626 100644 --- a/util.hpp +++ b/util.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace util { template @@ -20,7 +21,7 @@ struct is_optional : ::std::false_type {}; template struct is_optional<::std::optional> : ::std::true_type {}; -} +} // namespace util class Semaphore { public: @@ -232,3 +233,15 @@ std::string RegexReplaceMany(std::string str, std::string regexstr, F func) { return str; } + +inline void AddWidgetMenuHandler(Gtk::Widget *widget, Gtk::Menu &menu) { + widget->signal_button_press_event().connect([&menu](GdkEventButton *ev) -> bool { + if (ev->type == GDK_BUTTON_PRESS && ev->button == GDK_BUTTON_SECONDARY) { + menu.popup_at_pointer(reinterpret_cast(ev)); + return true; + } + return false; + // clang-format off + }, false); + // clang-format on +} -- cgit v1.2.3