Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.2.1, 5.3.0 RC1, 5.15.1
-
None
-
OS X 10.9
Description
When Qt sets the focus to a widget, the corresponding NSView is not made firstResponder. In the "normal" QWidget application this is no problem, since there is only a single QNSView for each window. It might lead to effects when some widget is forced to be native, but I haven't checked that in detail (it might not be a problem because everything is handled in the Qt-controlled QNSView class). It especially is an issue when embedding a native NSView with QMacCocoaViewContainer.
When clicking on a QWidget, AppKit automatically changes firstResponder due to the mouse event, but when programmatically setting the focus (e.g. from a menu action), the firstResponder stays at the previous NSView, so that receives and handles key events instead of the focus-QWidget.
I've attached a little test application. Give the top NSTextField focus, press cmd+L to set the Qt focus to the QTextEdit, type something. Expected: NSTextField loses focus, QTextEdit receives the keys. Actual: NSTextField keeps focus and receives the keys, QTextEdit doesn't receive the keys even though it thinks that it has keyboard focus.
You can uncomment the two lines in Widget::setFocusToTextEdit() to set the firstResponder correctly, and fix the example.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-39017 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
85914,3 | QPA: add QPlatformWindow::setFocus() | dev | qt/qtbase | Status: ABANDONED | -2 | 0 |
86102,3 | Widgets: unconditionally call requestActivate() when set focus | stable | qt/qtbase | Status: ABANDONED | -2 | 0 |
88441,2 | Widgets: unconditionally call requestActivate() when set focus on OS X | 5.3 | qt/qtbase | Status: ABANDONED | 0 | 0 |
98559,1 | Widgets: unconditionally call requestActivate() when set focus on OS X | 5.4 | qt/qtbase | Status: ABANDONED | -1 | 0 |