summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qcocoawindow_mac.mm
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-03-26 15:10:05 (GMT)
committerNorwegian Rock Cat <qt-info@nokia.com>2009-03-26 15:51:32 (GMT)
commitf5ef0eb1a6543abdd29e07c23de7fa1128f6d623 (patch)
tree8ed87026657dd93186144780c34acf11e4609b4b /src/gui/kernel/qcocoawindow_mac.mm
parent6bcf2ca6645409ffa1aaadd1bd302c6e86b5b028 (diff)
downloadQt-f5ef0eb1a6543abdd29e07c23de7fa1128f6d623.zip
Qt-f5ef0eb1a6543abdd29e07c23de7fa1128f6d623.tar.gz
Qt-f5ef0eb1a6543abdd29e07c23de7fa1128f6d623.tar.bz2
Fix a bug where lineedits in a second page of a stack widget would not get key events.
We need to be more explicit in setting the first responder, and a bit more agressing about rejecting it when called with no responder. It seems that Cocoa has a tendency to reset the first responder when lots of widgets get hidden or shown. During this it will call "makeFirstResponder" on the window with a nil responder. Doing this will reset our what Cocoa thinks is the focus widget, but Qt will still show a focus widget. The way to solve it is to reject the make first responder if the responder is nil. I'm not sure if there will be far reaching implications for this, but it seems to be doing the right thing at the moment. We also need to share this code between QCocoaWindow and QCocoaPanel. Thanks to the dynamic nature of objective-C we have to have a copy of the code in both places. It's unfortunate. Finally, it's also important to have the QWidget let Cocoa know it has focus after it has been created. So, make sure that is in sync. Task-number: 249296 Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/gui/kernel/qcocoawindow_mac.mm')
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 6b30444..ba121cd 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -86,6 +86,12 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
return YES;
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
/*
The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
get hit. We automatically say we can be first responder if we are a window.
@@ -173,6 +179,18 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self release];
}
+
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ if (responder == nil)
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)