mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
Browser: Add a simple context menu for hyperlinks
This only has "Open" and "Open in new tab" for now. :^)
This commit is contained in:
parent
f32989a3e7
commit
588e18721d
2 changed files with 16 additions and 0 deletions
|
@ -136,6 +136,19 @@ Tab::Tab()
|
|||
}
|
||||
};
|
||||
|
||||
m_link_context_menu = GUI::Menu::construct();
|
||||
m_link_context_menu->add_action(GUI::Action::create("Open", [this](auto&) {
|
||||
m_html_widget->on_link_click(m_link_context_menu_href, "", 0);
|
||||
}));
|
||||
m_link_context_menu->add_action(GUI::Action::create("Open in new tab", [this](auto&) {
|
||||
m_html_widget->on_link_click(m_link_context_menu_href, "_blank", 0);
|
||||
}));
|
||||
|
||||
m_html_widget->on_link_context_menu_request = [this](auto& href, auto& screen_position) {
|
||||
m_link_context_menu_href = href;
|
||||
m_link_context_menu->popup(screen_position);
|
||||
};
|
||||
|
||||
m_html_widget->on_title_change = [this](auto& title) {
|
||||
if (title.is_null()) {
|
||||
m_title = m_html_widget->main_frame().document()->url().to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue