mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:08:12 +00:00
Browser+LibWeb: Open link in new tab on Ctrl+Click :^)
This commit is contained in:
parent
d5d8e87d56
commit
5c2bdbf27f
4 changed files with 5 additions and 5 deletions
|
@ -133,13 +133,13 @@ Tab::Tab()
|
||||||
update_bookmark_button(url.to_string());
|
update_bookmark_button(url.to_string());
|
||||||
};
|
};
|
||||||
|
|
||||||
m_html_widget->on_link_click = [this](auto& href, auto& target) {
|
m_html_widget->on_link_click = [this](auto& href, auto& target, unsigned modifiers) {
|
||||||
if (href.starts_with("#")) {
|
if (href.starts_with("#")) {
|
||||||
auto anchor = href.substring_view(1, href.length() - 1);
|
auto anchor = href.substring_view(1, href.length() - 1);
|
||||||
m_html_widget->scroll_to_anchor(anchor);
|
m_html_widget->scroll_to_anchor(anchor);
|
||||||
} else {
|
} else {
|
||||||
auto url = m_html_widget->document()->complete_url(href);
|
auto url = m_html_widget->document()->complete_url(href);
|
||||||
if (target == "_blank")
|
if (target == "_blank" || modifiers == Mod_Ctrl)
|
||||||
on_tab_open_request(url);
|
on_tab_open_request(url);
|
||||||
else
|
else
|
||||||
m_html_widget->load(url);
|
m_html_widget->load(url);
|
||||||
|
|
|
@ -151,7 +151,7 @@ int main(int argc, char* argv[])
|
||||||
open_page(path);
|
open_page(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
html_view.on_link_click = [&](const String& href, auto&) {
|
html_view.on_link_click = [&](const String& href, auto&, unsigned) {
|
||||||
char* current_path = strdup(history.current().characters());
|
char* current_path = strdup(history.current().characters());
|
||||||
char* dir_path = dirname(current_path);
|
char* dir_path = dirname(current_path);
|
||||||
char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr);
|
char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr);
|
||||||
|
|
|
@ -238,7 +238,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
|
||||||
run_javascript_url(link->href());
|
run_javascript_url(link->href());
|
||||||
} else {
|
} else {
|
||||||
if (on_link_click)
|
if (on_link_click)
|
||||||
on_link_click(link->href(), link->target());
|
on_link_click(link->href(), link->target(), event.modifiers());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event.button() == GUI::MouseButton::Left) {
|
if (event.button() == GUI::MouseButton::Left) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
|
|
||||||
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
|
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
|
||||||
|
|
||||||
Function<void(const String& href, const String& target)> on_link_click;
|
Function<void(const String& href, const String& target, unsigned modifiers)> on_link_click;
|
||||||
Function<void(const String&)> on_link_hover;
|
Function<void(const String&)> on_link_hover;
|
||||||
Function<void(const String&)> on_title_change;
|
Function<void(const String&)> on_title_change;
|
||||||
Function<void(const URL&)> on_load_start;
|
Function<void(const URL&)> on_load_start;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue