1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +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:
networkException 2022-07-10 16:32:55 +02:00 committed by Andreas Kling
parent 5c1f1209fc
commit 6cd82f0100

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Emanuel Sprung <emanuel.sprung@gmail.com>
* Copyright (c) 2022, Jakob-Niklas See <git@nwex.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -200,12 +201,18 @@ void BookmarksBarWidget::model_did_update(unsigned)
button.set_relative_rect(rect);
button.set_focus_policy(GUI::FocusPolicy::TabFocus);
button.set_tooltip(url);
button.set_allowed_mouse_buttons_for_pressing(GUI::MouseButton::Primary | GUI::MouseButton::Middle);
button.on_click = [title, url, this](auto) {
if (on_bookmark_click)
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) {
m_context_menu_url = url;
m_context_menu->popup(context_menu_event.screen_position(), m_context_menu_default_action);