mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Browser: Mark default action in context menu of hyperlinks
This commit is contained in:
parent
a5f7b7e3e7
commit
b2de1ba779
Notes:
sideshowbarker
2024-07-19 03:01:48 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/b2de1ba7796 Pull-request: https://github.com/SerenityOS/serenity/pull/3340
2 changed files with 6 additions and 3 deletions
|
@ -151,9 +151,11 @@ Tab::Tab(Type type)
|
||||||
};
|
};
|
||||||
|
|
||||||
m_link_context_menu = GUI::Menu::construct();
|
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);
|
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&) {
|
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);
|
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) {
|
hooks().on_link_context_menu_request = [this](auto& url, auto& screen_position) {
|
||||||
m_link_context_menu_url = url;
|
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) {
|
hooks().on_link_middle_click = [this](auto& href, auto&, auto) {
|
||||||
|
|
|
@ -101,6 +101,7 @@ private:
|
||||||
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
|
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
|
||||||
|
|
||||||
RefPtr<GUI::Menu> m_link_context_menu;
|
RefPtr<GUI::Menu> m_link_context_menu;
|
||||||
|
RefPtr<GUI::Action> m_link_context_menu_default_action;
|
||||||
URL m_link_context_menu_url;
|
URL m_link_context_menu_url;
|
||||||
|
|
||||||
RefPtr<GUI::Menu> m_tab_context_menu;
|
RefPtr<GUI::Menu> m_tab_context_menu;
|
||||||
|
|
Loading…
Reference in a new issue