Browser: Mark default action in context menu of hyperlinks

This commit is contained in:
Ben Wiederhake 2020-08-29 10:56:42 +02:00 committed by Andreas Kling
parent a5f7b7e3e7
commit b2de1ba779
Notes: sideshowbarker 2024-07-19 03:01:48 +09:00
2 changed files with 6 additions and 3 deletions

View file

@ -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) {

View file

@ -101,6 +101,7 @@ private:
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
RefPtr<GUI::Menu> m_link_context_menu;
RefPtr<GUI::Action> m_link_context_menu_default_action;
URL m_link_context_menu_url;
RefPtr<GUI::Menu> m_tab_context_menu;