mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Adds an eventFilter, in order to steal keypresses.
This commit is contained in:
parent
235efcb2d4
commit
d62fb16a58
@ -22,6 +22,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
// Set up the emulation timer. Bluffer's guide: the QTimer will post an
|
||||
// event to an event loop. QThread is a thread with an event loop.
|
||||
@ -250,3 +251,21 @@ void MainWindow::dropEvent(QDropEvent* event) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Input capture.
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
|
||||
switch(event->type()) {
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease: {
|
||||
const auto keyEvent = static_cast<QKeyEvent *>(event);
|
||||
qDebug() << keyEvent->key() << " " << (event->type() == QEvent::KeyPress);
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,9 @@ class MainWindow : public QMainWindow {
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::MainWindow> ui;
|
||||
std::unique_ptr<QTimer> qTimer;
|
||||
|
@ -10,7 +10,7 @@ ScanTargetWidget::~ScanTargetWidget() {}
|
||||
void ScanTargetWidget::initializeGL() {
|
||||
glClearColor(0.5, 0.5, 1.0, 1.0);
|
||||
|
||||
qDebug() << "share context: " << bool(context()->shareGroup());
|
||||
// qDebug() << "share context: " << bool(context()->shareGroup());
|
||||
}
|
||||
|
||||
void ScanTargetWidget::paintGL() {
|
||||
|
Loading…
Reference in New Issue
Block a user