Implement focus handling of child windows for cocoa.
Change-Id: I1e05ef39aa67f8febdd27215d8ad05d26ece7caa Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
f7bd8652ca
commit
2692db542e
@ -114,6 +114,8 @@ public:
|
||||
bool setMouseGrabEnabled(bool grab);
|
||||
QMargins frameMargins() const;
|
||||
|
||||
void requestActivateWindow();
|
||||
|
||||
WId winId() const;
|
||||
void setParent(const QPlatformWindow *window);
|
||||
|
||||
|
@ -656,6 +656,13 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
|
||||
setOpacity(opacity);
|
||||
}
|
||||
|
||||
void QCocoaWindow::requestActivateWindow()
|
||||
{
|
||||
NSWindow *window = [m_contentView window];
|
||||
[ window makeFirstResponder : m_contentView ];
|
||||
[ window makeKeyWindow ];
|
||||
}
|
||||
|
||||
NSWindow * QCocoaWindow::createNSWindow()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
@ -82,6 +82,7 @@ QT_END_NAMESPACE
|
||||
|
||||
- (BOOL)isFlipped;
|
||||
- (BOOL)acceptsFirstResponder;
|
||||
- (BOOL)becomeFirstResponder;
|
||||
|
||||
- (void)handleMouseEvent:(NSEvent *)theEvent;
|
||||
- (void)mouseDown:(NSEvent *)theEvent;
|
||||
|
@ -330,8 +330,25 @@ static QTouchDevice *touchDevice = 0;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
QWindow *focusWindow = m_window;
|
||||
|
||||
// For widgets we need to do a bit of trickery as the window
|
||||
// to activate is the window of the top-level widget.
|
||||
if (m_window->metaObject()->className() == QStringLiteral("QWidgetWindow")) {
|
||||
while (focusWindow->parent()) {
|
||||
focusWindow = focusWindow->parent();
|
||||
}
|
||||
}
|
||||
QWindowSystemInterface::handleWindowActivated(focusWindow);
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
if ((m_window->flags() & Qt::ToolTip) == Qt::ToolTip)
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -758,6 +758,11 @@ void tst_QDateTimeEdit::displayFormat()
|
||||
|
||||
void tst_QDateTimeEdit::selectAndScrollWithKeys()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
QSKIP("QTBUG-23674");
|
||||
return;
|
||||
#endif
|
||||
|
||||
qApp->setActiveWindow(testWidget);
|
||||
testWidget->setDate(QDate(2004, 05, 11));
|
||||
testWidget->setDisplayFormat("dd/MM/yyyy");
|
||||
@ -768,9 +773,6 @@ void tst_QDateTimeEdit::selectAndScrollWithKeys()
|
||||
QTest::keyClick(testWidget, Qt::Key_Home);
|
||||
#endif
|
||||
QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
|
||||
#ifdef Q_OS_MAC
|
||||
QEXPECT_FAIL("", "QTBUG-23674", Abort);
|
||||
#endif
|
||||
QCOMPARE(testWidget->lineEdit()->selectedText(), QString("1"));
|
||||
QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
|
||||
QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
|
||||
|
Loading…
Reference in New Issue
Block a user