mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibWeb: Add hook when context menu is requested by right-clicking link
This commit is contained in:
parent
1061127ca7
commit
f32989a3e7
2 changed files with 11 additions and 5 deletions
|
@ -234,11 +234,16 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
|
||||||
if (RefPtr<HTMLAnchorElement> link = node->enclosing_link_element()) {
|
if (RefPtr<HTMLAnchorElement> link = node->enclosing_link_element()) {
|
||||||
dbg() << "HtmlView: clicking on a link to " << link->href();
|
dbg() << "HtmlView: clicking on a link to " << link->href();
|
||||||
|
|
||||||
if (link->href().starts_with("javascript:")) {
|
if (event.button() == GUI::MouseButton::Left) {
|
||||||
run_javascript_url(link->href());
|
if (link->href().starts_with("javascript:")) {
|
||||||
} else {
|
run_javascript_url(link->href());
|
||||||
if (on_link_click)
|
} else {
|
||||||
on_link_click(link->href(), link->target(), event.modifiers());
|
if (on_link_click)
|
||||||
|
on_link_click(link->href(), link->target(), event.modifiers());
|
||||||
|
}
|
||||||
|
} else if (event.button() == GUI::MouseButton::Right) {
|
||||||
|
if (on_link_context_menu_request)
|
||||||
|
on_link_context_menu_request(link->href(), event.position().translated(screen_relative_rect().location()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event.button() == GUI::MouseButton::Left) {
|
if (event.button() == GUI::MouseButton::Left) {
|
||||||
|
|
|
@ -58,6 +58,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, unsigned modifiers)> on_link_click;
|
Function<void(const String& href, const String& target, unsigned modifiers)> on_link_click;
|
||||||
|
Function<void(const String& href, const Gfx::Point& screen_position)> on_link_context_menu_request;
|
||||||
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