mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-09 01:20:46 +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
|
@ -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();
|
||||
|
|
|
@ -69,6 +69,9 @@ private:
|
|||
RefPtr<GUI::MenuBar> m_menubar;
|
||||
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
|
||||
|
||||
RefPtr<GUI::Menu> m_link_context_menu;
|
||||
String m_link_context_menu_href;
|
||||
|
||||
String m_title;
|
||||
RefPtr<const Gfx::Bitmap> m_icon;
|
||||
|
||||
|
|
Loading…
Reference in a new issue