aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-11-16 15:06:21 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-11-17 15:10:59 +0100
commit84d8bcd11756a0a076262295544c08765e267a51 (patch)
tree29e589345968c5c71d2d9262e067fcc0a61f7f81 /src/imports
parentbea92e4e0b2d58cfe88f247e9195dcb00e44e290 (diff)
macOS: don't use a focus frame around TextArea
As it turns out, text areas in general should not show a focus frame. We don't do that for widgets, and AppKit doesn't do that for NSTextView. And for good reason, we don't want to show a big focus ring around the whole text edit in e.g a text editor application. Change-Id: Idc344c9f8d9f4a11dce22b2d2284800f05cd551a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/controls/macos/TextArea.qml11
-rw-r--r--src/imports/nativestyle/util/qquickmacfocusframe.mm26
2 files changed, 2 insertions, 35 deletions
diff --git a/src/imports/controls/macos/TextArea.qml b/src/imports/controls/macos/TextArea.qml
index 38c8a7b7..f6b88303 100644
--- a/src/imports/controls/macos/TextArea.qml
+++ b/src/imports/controls/macos/TextArea.qml
@@ -38,15 +38,4 @@ import QtQuick
import QtQuick.NativeStyle as NativeStyle
NativeStyle.DefaultTextArea {
- id: control
-
- readonly property Item __focusFrameTarget: control
-
- background: Rectangle {
- color: control.palette.light
- // Since this delegate is a plain Rectangle, we need to tag it to know
- // that it's still the default one, and not some custom item set by the
- // application. Only in the former case do we wan't to show a focus frame.
- readonly property bool __isDefaultDelegate: true
- }
}
diff --git a/src/imports/nativestyle/util/qquickmacfocusframe.mm b/src/imports/nativestyle/util/qquickmacfocusframe.mm
index 7a30370c..14b5de60 100644
--- a/src/imports/nativestyle/util/qquickmacfocusframe.mm
+++ b/src/imports/nativestyle/util/qquickmacfocusframe.mm
@@ -132,8 +132,7 @@ QQuickFocusFrameDescription QQuickMacFocusFrame::getDescriptionForItem(QQuickIte
if (!target) {
// __focusFrameTarget points to the item in the control that should
// get the focus frame. This is usually the control itself, but can
- // sometimes be a child (CheckBox), and other times a grand parent
- // (a ScrollView that has a TextArea as child). We anyway require
+ // sometimes be a child (CheckBox). We anyway require
// this property to be set if we are to show the focus frame around
// the control in the first place. So for controls that don't want
// a frame (ProgressBar), we simply skip setting it.
@@ -146,27 +145,6 @@ QQuickFocusFrameDescription QQuickMacFocusFrame::getDescriptionForItem(QQuickIte
return QQuickFocusFrameDescription::Invalid;
}
- if (qobject_cast<QQuickTextArea *>(target)) {
- // Special case: if the target is a TextArea, we check if it's the only
- // child inside a ScrollArea, Flickable, or Frame. If that is the case, we
- // redirect the focus frame to be around the container instead.
- const auto parent1 = target->parentItem();
- if (parent1 && parent1->childItems().count() == 1) {
- const auto parent2 = parent1->parentItem();
- const auto parent3 = parent2 ? parent2->parentItem() : nullptr;
- if (qobject_cast<QQuickScrollView *>(parent3)) {
- target = parent3;
- qCDebug(lcFocusFrame) << "redirecting target to ScrollView:" << target;
- } else if (qobject_cast<QQuickFlickable *>(parent2)) {
- target = parent2;
- qCDebug(lcFocusFrame) << "redirecting target to Flickable:" << target;
- } else if (qobject_cast<QQuickFrame *>(parent2)) {
- target = parent2;
- qCDebug(lcFocusFrame) << "redirecting target to Frame:" << target;
- }
- }
- }
-
// If the control gives us a QQuickStyleItem, we use that to configure the focus frame.
// By default we assume that the background delegate is a QQuickStyleItem, but the
// control can override this by setting __focusFrameStyleItem.
@@ -182,7 +160,7 @@ QQuickFocusFrameDescription QQuickMacFocusFrame::getDescriptionForItem(QQuickIte
if (QQuickStyleItem *styleItem = qobject_cast<QQuickStyleItem *>(item))
return { target, QQuickStyleMargins(styleItem->layoutMargins()), styleItem->focusFrameRadius() };
- // Some controls don't have a QQuickStyleItem (TextArea). But if the __focusFrameStyleItem
+ // Some controls don't have a QQuickStyleItem. But if the __focusFrameStyleItem
// has a "__isDefaultDelegate" property set, we show a default focus frame instead.
if (item->property("__isDefaultDelegate").toBool() == true) {
qCDebug(lcFocusFrame) << "'__isDefaultDelegate' property found, showing a default focus frame";