diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-18 04:12:27 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-18 04:12:27 +0200 |
commit | a747a10eabd12427bf3c4626e6929041aa81fa7c (patch) | |
tree | aef86e888d07d7edf18adafa22687409f535875d /LibGUI/GWidget.h | |
parent | e74b5bc054abece021ec38bf2f12a3fb5b659a75 (diff) | |
download | serenity-a747a10eabd12427bf3c4626e6929041aa81fa7c.zip |
LibGUI: Refactor context menus to be event-driven instead of declarative.
The declarative approach had way too many limitations. This patch adds a
context menu event that can be hooked to prepare a custom context menu on
demand just-in-time. :^)
Diffstat (limited to 'LibGUI/GWidget.h')
-rw-r--r-- | LibGUI/GWidget.h | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index 5fc98de9f5..1b53543cd5 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -42,11 +42,6 @@ public: bool is_enabled() const { return m_enabled; } void set_enabled(bool); - enum class ContextMenuMode { SwallowMouseEvent, PassthroughMouseEvent }; - - const GMenu* context_menu() const { return m_context_menu.ptr(); } - void set_context_menu(OwnPtr<GMenu>&&, ContextMenuMode = ContextMenuMode::SwallowMouseEvent); - virtual void event(CEvent&) override; virtual void paint_event(GPaintEvent&); virtual void resize_event(GResizeEvent&); @@ -59,6 +54,7 @@ public: virtual void mouseup_event(GMouseEvent&); virtual void click_event(GMouseEvent&); virtual void doubleclick_event(GMouseEvent&); + virtual void context_menu_event(GContextMenuEvent&); virtual void focusin_event(CEvent&); virtual void focusout_event(CEvent&); virtual void enter_event(CEvent&); @@ -206,6 +202,4 @@ private: bool m_enabled { true }; CElapsedTimer m_click_clock; - OwnPtr<GMenu> m_context_menu; - ContextMenuMode m_context_menu_mode { ContextMenuMode::SwallowMouseEvent }; }; |