Merge pull request #42 from shemanaev/mouse-buttons-fix

Add Back/Forward mouse buttons handler.
This commit is contained in:
Ian Walton 2021-04-18 12:08:39 -04:00 committed by GitHub
commit e15cff1aa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@
#include "settings/SettingsComponent.h"
#include "input/InputKeyboard.h"
#include "KonvergoWindow.h"
#include <QQuickItem>
#include <QKeyEvent>
#include <QObject>
@ -85,6 +86,22 @@ bool EventFilter::eventFilter(QObject* watched, QEvent* event)
}
}
}
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent) {
QQuickItem* webView = window->findChild<QQuickItem*>("web");
if (mouseEvent->button() == Qt::BackButton)
QMetaObject::invokeMethod(webView, "goBack");
if (mouseEvent->button() == Qt::ForwardButton)
QMetaObject::invokeMethod(webView, "goForward");
}
}
return QObject::eventFilter(watched, event);
}