viewertexteditor: fixed UI issues on macOS

This commit is contained in:
itsmattkc
2022-03-30 12:04:36 -07:00
parent 102b782215
commit 2a74522aa6
3 changed files with 17 additions and 2 deletions
+7 -1
View File
@@ -344,7 +344,7 @@ void ViewerDisplayWidget::mouseDoubleClickEvent(QMouseEvent *event)
text_edit->setGeometry(transformed_geom.toRect());
ViewerTextEditorToolBar *toolbar = new ViewerTextEditorToolBar(this);
toolbar->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
toolbar->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
toolbar->resize(toolbar->sizeHint());
QPoint pos = mapToGlobal(QPoint(transformed_geom.x(), transformed_geom.y() - toolbar->height()));
@@ -376,6 +376,12 @@ void ViewerDisplayWidget::mouseDoubleClickEvent(QMouseEvent *event)
// Start text cursor where the user clicked
text_edit->setTextCursor(text_edit->cursorForPosition(text_edit_pos));
// HACK: On macOS, for some reason the QDockWidget receives focus before the
// ViewerTextEditor, causing the editor to close prematurely. However this only
// happens the first time the editor receives focus and not subsequent times, so
// if we get it to only listen after the first one, this solves the problem.
text_edit->SetListenToFocusEvents(true);
});
break;
}