summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-03-11 12:37:22 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-03-17 14:47:55 (GMT)
commit4256bd2141fef53f9e69a51b966bd85f67a6cf54 (patch)
tree808ac1f717b2179d84d2d7743e445a4f8b27a257 /src/gui/kernel
parent77230f7ec9e78ec2d57629ea934ceb1d59eb391e (diff)
downloadQt-4256bd2141fef53f9e69a51b966bd85f67a6cf54.zip
Qt-4256bd2141fef53f9e69a51b966bd85f67a6cf54.tar.gz
Qt-4256bd2141fef53f9e69a51b966bd85f67a6cf54.tar.bz2
Fixed focus handling when Qt is embedded into Cocoa app.
When a Qt widget gets focus we should call setFocus() on it to make sure the focus chain is properly set. Reviewed-by: Prasanth
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 99c0bb1..e745074 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -1032,11 +1032,16 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
return NO;
+ // disabled widget shouldn't get focus even if it's a window.
+ // hence disabled windows will not get any key or mouse events.
+ if (!qwidget->isEnabled())
+ return NO;
// Before accepting the focus for a window, we check that
// the focusWidget (if any) is not contained in the same window.
- if (qwidget->isWindow() && (!qApp->focusWidget()
- || qApp->focusWidget()->window() != qwidget))
+ if (qwidget->isWindow() && !qt_widget_private(qwidget)->topData()->embedded
+ && (!qApp->focusWidget() || qApp->focusWidget()->window() != qwidget)) {
return YES; // Always do it, so that windows can accept key press events.
+ }
return qwidget->focusPolicy() != Qt::NoFocus;
}
@@ -1047,7 +1052,16 @@ static int qCocoaViewCount = 0;
// Seems like the following test only triggers if this
// view is inside a QMacNativeWidget:
if (qwidget == QApplication::focusWidget())
- QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
+ qwidget->clearFocus();
+ return YES;
+}
+
+- (BOOL)becomeFirstResponder
+{
+ // see the comment in the acceptsFirstResponder - if the window "stole" focus
+ // let it become the responder, but don't tell Qt
+ if (!QApplication::focusWidget() && qwidget->focusPolicy() != Qt::NoFocus)
+ qwidget->setFocus(Qt::OtherFocusReason);
return YES;
}