macOS: Support [NSPanel becomesKeyOnlyIfNeeded]
We don't set this flag ourselves, but clients may do via winId(). If set, the panel will only activate if a view with needsPanelToBecomeKey is clicked. We do not implement needsPanelToBecomeKey in QNSView, which we ideally should, by e.g. looking at the IME hints. This still works as expected, as QtWidgets will make sure to activate the window as part of the normal focus handling. For other use-cases the user will have to catch the mouse event and activate the window manually. Change-Id: I4bacdd44b2f7df5920c6334806303bb5eb502b48 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
d04c9e23ff
commit
a962bbec07
@ -377,7 +377,14 @@ void QCocoaWindow::setVisible(bool visible)
|
||||
// Show the window as application modal
|
||||
eventDispatcher()->beginModalSession(window());
|
||||
} else if (m_view.window.canBecomeKeyWindow) {
|
||||
if (!NSApp.modalWindow || m_view.window.worksWhenModal)
|
||||
bool shouldBecomeKeyNow = !NSApp.modalWindow || m_view.window.worksWhenModal;
|
||||
|
||||
// Panels with becomesKeyOnlyIfNeeded set should not activate until a view
|
||||
// with needsPanelToBecomeKey, for example a line edit, is clicked.
|
||||
if ([m_view.window isKindOfClass:[NSPanel class]])
|
||||
shouldBecomeKeyNow &= !(static_cast<NSPanel*>(m_view.window).becomesKeyOnlyIfNeeded);
|
||||
|
||||
if (shouldBecomeKeyNow)
|
||||
[m_view.window makeKeyAndOrderFront:nil];
|
||||
else
|
||||
[m_view.window orderFront:nil];
|
||||
|
Loading…
Reference in New Issue
Block a user