mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +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) {
|
m_html_widget->on_title_change = [this](auto& title) {
|
||||||
if (title.is_null()) {
|
if (title.is_null()) {
|
||||||
m_title = m_html_widget->main_frame().document()->url().to_string();
|
m_title = m_html_widget->main_frame().document()->url().to_string();
|
||||||
|
|
|
@ -69,6 +69,9 @@ private:
|
||||||
RefPtr<GUI::MenuBar> m_menubar;
|
RefPtr<GUI::MenuBar> m_menubar;
|
||||||
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
|
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
|
||||||
|
|
||||||
|
RefPtr<GUI::Menu> m_link_context_menu;
|
||||||
|
String m_link_context_menu_href;
|
||||||
|
|
||||||
String m_title;
|
String m_title;
|
||||||
RefPtr<const Gfx::Bitmap> m_icon;
|
RefPtr<const Gfx::Bitmap> m_icon;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue