From b2de1ba7796a456858e063638ed0c55a13e3c6c7 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 29 Aug 2020 10:56:42 +0200 Subject: [PATCH] Browser: Mark default action in context menu of hyperlinks --- Applications/Browser/Tab.cpp | 8 +++++--- Applications/Browser/Tab.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index d56878e8f6c..300aa1922ca 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -151,9 +151,11 @@ Tab::Tab(Type type) }; m_link_context_menu = GUI::Menu::construct(); - m_link_context_menu->add_action(GUI::Action::create("Open", [this](auto&) { + auto default_action = GUI::Action::create("Open", [this](auto&) { hooks().on_link_click(m_link_context_menu_url, "", 0); - })); + }); + m_link_context_menu->add_action(default_action); + m_link_context_menu_default_action = default_action; m_link_context_menu->add_action(GUI::Action::create("Open in new tab", [this](auto&) { hooks().on_link_click(m_link_context_menu_url, "_blank", 0); })); @@ -174,7 +176,7 @@ Tab::Tab(Type type) hooks().on_link_context_menu_request = [this](auto& url, auto& screen_position) { m_link_context_menu_url = url; - m_link_context_menu->popup(screen_position); + m_link_context_menu->popup(screen_position, m_link_context_menu_default_action); }; hooks().on_link_middle_click = [this](auto& href, auto&, auto) { diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index 5598cff65b3..99d03fffa97 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -101,6 +101,7 @@ private: RefPtr m_toolbar_container; RefPtr m_link_context_menu; + RefPtr m_link_context_menu_default_action; URL m_link_context_menu_url; RefPtr m_tab_context_menu;