mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
Browser: Allow opening bookmarks in new tab on middle mouse click
This patch updates all bookmark buttons to allow middle mouse button pressing and respond to a middle mouse click by opening the url in a new tab.
This commit is contained in:
parent
5c1f1209fc
commit
6cd82f0100
1 changed files with 7 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Emanuel Sprung <emanuel.sprung@gmail.com>
|
* Copyright (c) 2020, Emanuel Sprung <emanuel.sprung@gmail.com>
|
||||||
|
* Copyright (c) 2022, Jakob-Niklas See <git@nwex.de>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -200,12 +201,18 @@ void BookmarksBarWidget::model_did_update(unsigned)
|
||||||
button.set_relative_rect(rect);
|
button.set_relative_rect(rect);
|
||||||
button.set_focus_policy(GUI::FocusPolicy::TabFocus);
|
button.set_focus_policy(GUI::FocusPolicy::TabFocus);
|
||||||
button.set_tooltip(url);
|
button.set_tooltip(url);
|
||||||
|
button.set_allowed_mouse_buttons_for_pressing(GUI::MouseButton::Primary | GUI::MouseButton::Middle);
|
||||||
|
|
||||||
button.on_click = [title, url, this](auto) {
|
button.on_click = [title, url, this](auto) {
|
||||||
if (on_bookmark_click)
|
if (on_bookmark_click)
|
||||||
on_bookmark_click(url, OpenInNewTab::No);
|
on_bookmark_click(url, OpenInNewTab::No);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
button.on_middle_mouse_click = [title, url, this](auto) {
|
||||||
|
if (on_bookmark_click)
|
||||||
|
on_bookmark_click(url, OpenInNewTab::Yes);
|
||||||
|
};
|
||||||
|
|
||||||
button.on_context_menu_request = [this, url](auto& context_menu_event) {
|
button.on_context_menu_request = [this, url](auto& context_menu_event) {
|
||||||
m_context_menu_url = url;
|
m_context_menu_url = url;
|
||||||
m_context_menu->popup(context_menu_event.screen_position(), m_context_menu_default_action);
|
m_context_menu->popup(context_menu_event.screen_position(), m_context_menu_default_action);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue