1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Ensures ScanTargetWidget doesn't eat irrelevant keypresses.

This commit is contained in:
Thomas Harte 2020-07-04 19:12:34 -04:00
parent cdda3f74ab
commit 366793498a
2 changed files with 9 additions and 0 deletions

View File

@ -715,6 +715,8 @@ void MainWindow::setUIPhase(UIPhase phase) {
// widgets aren't still selectable after a machine starts.
if(phase != UIPhase::SelectingMachine) {
ui->openGLWidget->setFocus();
} else {
ui->startMachineButton->setDefault(true);
}
// Indicate whether to catch mouse input.

View File

@ -143,13 +143,20 @@ void ScanTargetWidget::setMouseDelegate(MouseDelegate *delegate) {
}
void ScanTargetWidget::keyPressEvent(QKeyEvent *event) {
// Use CTRL+Escape to end mouse captured mode, if currently captured; otherwise ignore the event.
// Empirical note: control actually appears to mean command on the Mac. I have no idea what the
// Mac's command key would actually be as a modifier. Fingers crossed control means control
// elsewhere (?).
if(mouseIsCaptured && event->key() == Qt::Key_Escape && event->modifiers()&Qt::ControlModifier) {
releaseMouse();
QCursor cursor;
cursor.setShape(Qt::ArrowCursor);
setCursor(cursor);
return;
}
event->ignore();
}
void ScanTargetWidget::releaseMouse() {