Allow middle-click to open new tab when text is selected

If text is selected, middle-click will not be forwarded to the function
that opens the link in a new tab. So this change will deselect any
selected text before trying to open a new tab.

Fixes #253
This commit is contained in:
Tomas Åkesson 2023-04-04 21:45:28 +02:00 committed by Felix Queißner
parent d937a0c32e
commit d47e3d3f54
1 changed files with 3 additions and 0 deletions

View File

@ -48,6 +48,9 @@ KristallTextBrowser::KristallTextBrowser(QWidget *parent) :
void KristallTextBrowser::mouseReleaseEvent(QMouseEvent *event)
{
if(event->button() == Qt::MiddleButton) {
// Deselect any selection. Otherwise the click won't register.
setTextCursor(cursorForPosition(event->pos()));
// Fake a middle-click event here
QMouseEvent fake_event {
event->type(),