2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
#ifndef QQUICKTEXTINPUT_P_H
|
|
|
|
#define QQUICKTEXTINPUT_P_H
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2015-10-05 08:45:54 +00:00
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
#include "qquickimplicitsizeitem_p.h"
|
Invalidate text when application fonts are added or removed
We had multiple related issues due to application fonts being added
or removed during the application lifetime.
1. If a text had font family "foo" set, and this font did not
exist at the time, then loading "foo" at a later stage would not
update the text to use the correct font, since the result of
the previous request had been cached.
2. A variation of #1 was if the font "foo" was loaded by a FontLoader
in the scene and referred to by name in the text component. In this
case, there was a race condition, where the font lookup would sometimes
yield different results on the main thread and on the render thread,
and text would be garbled.
3. When a font was removed from the font database, then references to
it would remain in the caches (glyph cache + font cache) in the render
thread. With certain backends (DirectWrite, CoreText) this caused errors
or even crashes, as the cached font engines would be referring to data
that had been removed.
The work-around for #1 and #2 was merely to avoid hardcoding names for
fonts, but instead getting them from the FontLoader. This way, you can
avoid requesting the font family before it is available (and thus avoid
caching the wrong result). However, for #3 there is no known work-around.
This patch fixes all three (together with a smaller patch for qtbase) by
invalidating all text and related caches in Qt Quick when fonts are
either added or removed from the font database. This does add some
overhead if font loading happens during runtime, but the alternative is
broken behavior and dangling pointers.
This is done during the synchronization step. Before synchronization,
the font cache is flushed and all text components are marked for update,
so that fonts are re-requested against the new font database.
After synchronization, we delete all distance field glyph caches which
are not currently in use, to avoid having references to stale application
font data in the list.
[ChangeLog][Text] Fix multiple issues with usage of application fonts when
they are added or removed during the lifetime of the application.
Task-number: QTBUG-100697
Task-number: QDS-1142
Change-Id: Ib309e54e0ee97b6be6d2a7211964043fd51c9ec5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-18 11:57:01 +00:00
|
|
|
#include "qquicktextinterface_p.h"
|
2011-12-15 01:36:54 +00:00
|
|
|
#include <QtGui/qtextoption.h>
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#if QT_CONFIG(validator)
|
2011-04-27 12:13:26 +00:00
|
|
|
#include <QtGui/qvalidator.h>
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#endif
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
class QQuickTextInputPrivate;
|
Invalidate text when application fonts are added or removed
We had multiple related issues due to application fonts being added
or removed during the application lifetime.
1. If a text had font family "foo" set, and this font did not
exist at the time, then loading "foo" at a later stage would not
update the text to use the correct font, since the result of
the previous request had been cached.
2. A variation of #1 was if the font "foo" was loaded by a FontLoader
in the scene and referred to by name in the text component. In this
case, there was a race condition, where the font lookup would sometimes
yield different results on the main thread and on the render thread,
and text would be garbled.
3. When a font was removed from the font database, then references to
it would remain in the caches (glyph cache + font cache) in the render
thread. With certain backends (DirectWrite, CoreText) this caused errors
or even crashes, as the cached font engines would be referring to data
that had been removed.
The work-around for #1 and #2 was merely to avoid hardcoding names for
fonts, but instead getting them from the FontLoader. This way, you can
avoid requesting the font family before it is available (and thus avoid
caching the wrong result). However, for #3 there is no known work-around.
This patch fixes all three (together with a smaller patch for qtbase) by
invalidating all text and related caches in Qt Quick when fonts are
either added or removed from the font database. This does add some
overhead if font loading happens during runtime, but the alternative is
broken behavior and dangling pointers.
This is done during the synchronization step. Before synchronization,
the font cache is flushed and all text components are marked for update,
so that fonts are re-requested against the new font database.
After synchronization, we delete all distance field glyph caches which
are not currently in use, to avoid having references to stale application
font data in the list.
[ChangeLog][Text] Fix multiple issues with usage of application fonts when
they are added or removed during the lifetime of the application.
Task-number: QTBUG-100697
Task-number: QDS-1142
Change-Id: Ib309e54e0ee97b6be6d2a7211964043fd51c9ec5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-18 11:57:01 +00:00
|
|
|
class Q_QUICK_PRIVATE_EXPORT QQuickTextInput : public QQuickImplicitSizeItem, public QQuickTextInterface
|
2011-04-27 12:13:26 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
Invalidate text when application fonts are added or removed
We had multiple related issues due to application fonts being added
or removed during the application lifetime.
1. If a text had font family "foo" set, and this font did not
exist at the time, then loading "foo" at a later stage would not
update the text to use the correct font, since the result of
the previous request had been cached.
2. A variation of #1 was if the font "foo" was loaded by a FontLoader
in the scene and referred to by name in the text component. In this
case, there was a race condition, where the font lookup would sometimes
yield different results on the main thread and on the render thread,
and text would be garbled.
3. When a font was removed from the font database, then references to
it would remain in the caches (glyph cache + font cache) in the render
thread. With certain backends (DirectWrite, CoreText) this caused errors
or even crashes, as the cached font engines would be referring to data
that had been removed.
The work-around for #1 and #2 was merely to avoid hardcoding names for
fonts, but instead getting them from the FontLoader. This way, you can
avoid requesting the font family before it is available (and thus avoid
caching the wrong result). However, for #3 there is no known work-around.
This patch fixes all three (together with a smaller patch for qtbase) by
invalidating all text and related caches in Qt Quick when fonts are
either added or removed from the font database. This does add some
overhead if font loading happens during runtime, but the alternative is
broken behavior and dangling pointers.
This is done during the synchronization step. Before synchronization,
the font cache is flushed and all text components are marked for update,
so that fonts are re-requested against the new font database.
After synchronization, we delete all distance field glyph caches which
are not currently in use, to avoid having references to stale application
font data in the list.
[ChangeLog][Text] Fix multiple issues with usage of application fonts when
they are added or removed during the lifetime of the application.
Task-number: QTBUG-100697
Task-number: QDS-1142
Change-Id: Ib309e54e0ee97b6be6d2a7211964043fd51c9ec5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-18 11:57:01 +00:00
|
|
|
Q_INTERFACES(QQuickTextInterface)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
|
|
|
|
Q_PROPERTY(int length READ length NOTIFY textChanged FINAL)
|
|
|
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
|
|
|
|
Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged FINAL)
|
|
|
|
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged FINAL)
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged FINAL)
|
|
|
|
Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged FINAL)
|
|
|
|
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged FINAL)
|
|
|
|
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged FINAL)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged FINAL)
|
|
|
|
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged FINAL)
|
|
|
|
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged FINAL)
|
|
|
|
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged FINAL)
|
|
|
|
Q_PROPERTY(QQmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged FINAL)
|
|
|
|
Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode NOTIFY overwriteModeChanged FINAL)
|
|
|
|
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged FINAL)
|
|
|
|
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged FINAL)
|
|
|
|
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged FINAL)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged FINAL)
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#if QT_CONFIG(validator)
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL)
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#endif
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged FINAL)
|
|
|
|
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged FINAL)
|
|
|
|
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged FINAL)
|
|
|
|
Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged FINAL)
|
|
|
|
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged FINAL)
|
|
|
|
Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay NOTIFY passwordMaskDelayChanged REVISION(2, 4) FINAL)
|
|
|
|
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged FINAL)
|
|
|
|
Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7) FINAL)
|
|
|
|
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged FINAL)
|
|
|
|
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged FINAL)
|
|
|
|
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged FINAL)
|
|
|
|
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged FINAL)
|
|
|
|
Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged FINAL)
|
|
|
|
Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged FINAL)
|
|
|
|
Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged FINAL)
|
|
|
|
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL)
|
|
|
|
Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged FINAL)
|
|
|
|
Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged FINAL)
|
|
|
|
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged FINAL)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2023-05-26 14:49:20 +00:00
|
|
|
Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6) FINAL)
|
|
|
|
Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6) FINAL)
|
|
|
|
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6) FINAL)
|
|
|
|
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6) FINAL)
|
|
|
|
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6) FINAL)
|
2019-08-21 16:34:21 +00:00
|
|
|
QML_NAMED_ELEMENT(TextInput)
|
2020-01-16 12:42:11 +00:00
|
|
|
QML_ADDED_IN_VERSION(2, 0)
|
TextInput/Field: selectByMouse default=true, but not on touchscreens
When you drag a finger across a TextInput or TextField, it should
not select text.
- your finger probably covers several characters, so you can't see where
you're selecting until afterwards
- if the item is in a Flickable, flicking by touch should be prioritized
- if flicking happens, the text cursor should not move; but to avoid
losing too much functionality, we allow it to move on release, if
the TextInput or TextField gets the release (i.e. if it still has
the exclusive grab)
- TextField's pressed, pressAndHold and released signals continue to
behave the same with touch as with mouse
So now we distinguish mouse events that are synthesized from non-mouse
devices and avoid mouse-like behaviors as described above, but there is
no behavior change if the event comes from an actual mouse or touchpad.
Since most users want selecting text by mouse to "just work", and an
actual mouse is precise enough to do so, and dragging a Flickable with
the mouse is unintuitive (since most UIs don't allow it and most mice
have wheels), selectByMouse now defaults to true, and has the stricter
meaning that its name implies. To select text on a touchscreen, the
end-user needs to rely on text-selection handles, which are provided on
touch-centric mobile platforms, and could also be implemented from
scratch if someone builds a custom text field using TextInput.
[ChangeLog][QtQuick][TextInput] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
using an import version < 6.4.
[ChangeLog][Controls][TextField] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
using an import version < 6.4.
Pick-to: 6.4
Task-number: QTBUG-10684
Task-number: QTBUG-38934
Task-number: QTBUG-101205
Change-Id: I6d3158dd48896a0bed37cbc0b2da01d313a499f8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-02-24 08:00:48 +00:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
|
|
|
|
QML_ADDED_IN_VERSION(6, 4)
|
|
|
|
#endif
|
2015-02-02 16:51:16 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
public:
|
2018-02-21 09:41:54 +00:00
|
|
|
QQuickTextInput(QQuickItem * parent=nullptr);
|
2011-10-14 08:51:42 +00:00
|
|
|
~QQuickTextInput();
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2017-09-20 18:57:39 +00:00
|
|
|
void componentComplete() override;
|
2011-12-15 01:36:54 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
enum EchoMode {//To match QLineEdit::EchoMode
|
|
|
|
Normal,
|
|
|
|
NoEcho,
|
|
|
|
Password,
|
|
|
|
PasswordEchoOnEdit
|
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(EchoMode)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
enum HAlignment {
|
|
|
|
AlignLeft = Qt::AlignLeft,
|
|
|
|
AlignRight = Qt::AlignRight,
|
|
|
|
AlignHCenter = Qt::AlignHCenter
|
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(HAlignment)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2011-12-15 01:36:54 +00:00
|
|
|
enum VAlignment {
|
|
|
|
AlignTop = Qt::AlignTop,
|
|
|
|
AlignBottom = Qt::AlignBottom,
|
|
|
|
AlignVCenter = Qt::AlignVCenter
|
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(VAlignment)
|
2011-12-15 01:36:54 +00:00
|
|
|
|
|
|
|
enum WrapMode {
|
|
|
|
NoWrap = QTextOption::NoWrap,
|
|
|
|
WordWrap = QTextOption::WordWrap,
|
|
|
|
WrapAnywhere = QTextOption::WrapAnywhere,
|
|
|
|
WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
|
|
|
|
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
|
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(WrapMode)
|
2011-12-15 01:36:54 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
enum SelectionMode {
|
|
|
|
SelectCharacters,
|
|
|
|
SelectWords
|
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(SelectionMode)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
enum CursorPosition {
|
|
|
|
CursorBetweenCharacters,
|
|
|
|
CursorOnCharacter
|
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(CursorPosition)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2012-07-04 12:56:38 +00:00
|
|
|
enum RenderType { QtRendering,
|
2023-10-10 12:23:33 +00:00
|
|
|
NativeRendering,
|
|
|
|
CurveRendering
|
2012-07-04 12:56:38 +00:00
|
|
|
};
|
2015-05-13 07:59:40 +00:00
|
|
|
Q_ENUM(RenderType)
|
2011-12-15 01:36:54 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
//Auxilliary functions needed to control the TextInput from QML
|
2013-05-08 14:22:39 +00:00
|
|
|
Q_INVOKABLE void positionAt(QQmlV4Function *args) const;
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_INVOKABLE QRectF positionToRectangle(int pos) const;
|
|
|
|
Q_INVOKABLE void moveCursorSelection(int pos);
|
|
|
|
Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
|
|
|
|
|
2012-07-04 12:56:38 +00:00
|
|
|
RenderType renderType() const;
|
|
|
|
void setRenderType(RenderType renderType);
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &);
|
|
|
|
|
2012-01-04 00:53:26 +00:00
|
|
|
int length() const;
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
QFont font() const;
|
|
|
|
void setFont(const QFont &font);
|
|
|
|
|
|
|
|
QColor color() const;
|
|
|
|
void setColor(const QColor &c);
|
|
|
|
|
|
|
|
QColor selectionColor() const;
|
|
|
|
void setSelectionColor(const QColor &c);
|
|
|
|
|
|
|
|
QColor selectedTextColor() const;
|
|
|
|
void setSelectedTextColor(const QColor &c);
|
|
|
|
|
|
|
|
HAlignment hAlign() const;
|
|
|
|
void setHAlign(HAlignment align);
|
|
|
|
void resetHAlign();
|
|
|
|
HAlignment effectiveHAlign() const;
|
|
|
|
|
2011-12-15 01:36:54 +00:00
|
|
|
VAlignment vAlign() const;
|
|
|
|
void setVAlign(VAlignment align);
|
|
|
|
|
|
|
|
WrapMode wrapMode() const;
|
|
|
|
void setWrapMode(WrapMode w);
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
bool isReadOnly() const;
|
|
|
|
void setReadOnly(bool);
|
|
|
|
|
|
|
|
bool isCursorVisible() const;
|
|
|
|
void setCursorVisible(bool on);
|
|
|
|
|
|
|
|
int cursorPosition() const;
|
|
|
|
void setCursorPosition(int cp);
|
|
|
|
|
2012-02-23 04:11:48 +00:00
|
|
|
QRectF cursorRectangle() const;
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
int selectionStart() const;
|
|
|
|
int selectionEnd() const;
|
|
|
|
|
|
|
|
QString selectedText() const;
|
|
|
|
|
|
|
|
int maxLength() const;
|
|
|
|
void setMaxLength(int ml);
|
|
|
|
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#if QT_CONFIG(validator)
|
2011-04-27 12:13:26 +00:00
|
|
|
QValidator * validator() const;
|
|
|
|
void setValidator(QValidator* v);
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#endif
|
2014-09-09 15:35:33 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
QString inputMask() const;
|
|
|
|
void setInputMask(const QString &im);
|
|
|
|
|
|
|
|
EchoMode echoMode() const;
|
|
|
|
void setEchoMode(EchoMode echo);
|
|
|
|
|
|
|
|
QString passwordCharacter() const;
|
|
|
|
void setPasswordCharacter(const QString &str);
|
|
|
|
|
2014-03-11 10:04:52 +00:00
|
|
|
int passwordMaskDelay() const;
|
|
|
|
void setPasswordMaskDelay(int delay);
|
|
|
|
void resetPasswordMaskDelay();
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
QString displayText() const;
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 7) QString preeditText() const;
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
QQmlComponent* cursorDelegate() const;
|
|
|
|
void setCursorDelegate(QQmlComponent*);
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2015-08-28 15:11:57 +00:00
|
|
|
bool overwriteMode() const;
|
|
|
|
void setOverwriteMode(bool overwrite);
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
bool focusOnPress() const;
|
|
|
|
void setFocusOnPress(bool);
|
|
|
|
|
|
|
|
bool autoScroll() const;
|
|
|
|
void setAutoScroll(bool);
|
|
|
|
|
|
|
|
bool selectByMouse() const;
|
|
|
|
void setSelectByMouse(bool);
|
|
|
|
|
|
|
|
SelectionMode mouseSelectionMode() const;
|
|
|
|
void setMouseSelectionMode(SelectionMode mode);
|
|
|
|
|
2012-01-20 06:10:23 +00:00
|
|
|
bool persistentSelection() const;
|
|
|
|
void setPersistentSelection(bool persist);
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
bool hasAcceptableInput() const;
|
|
|
|
|
2016-11-16 13:22:36 +00:00
|
|
|
#if QT_CONFIG(im)
|
2017-09-20 18:57:39 +00:00
|
|
|
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
|
2012-11-22 17:47:45 +00:00
|
|
|
#endif
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2017-09-20 18:57:39 +00:00
|
|
|
QRectF boundingRect() const override;
|
|
|
|
QRectF clipRect() const override;
|
2012-04-19 01:08:28 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
bool canPaste() const;
|
|
|
|
|
2012-01-10 01:52:43 +00:00
|
|
|
bool canUndo() const;
|
|
|
|
bool canRedo() const;
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
bool isInputMethodComposing() const;
|
|
|
|
|
2012-02-15 12:30:44 +00:00
|
|
|
Qt::InputMethodHints inputMethodHints() const;
|
|
|
|
void setInputMethodHints(Qt::InputMethodHints hints);
|
2011-05-04 07:53:51 +00:00
|
|
|
|
2012-01-04 00:53:26 +00:00
|
|
|
Q_INVOKABLE QString getText(int start, int end) const;
|
|
|
|
|
2012-02-07 01:57:42 +00:00
|
|
|
qreal contentWidth() const;
|
|
|
|
qreal contentHeight() const;
|
|
|
|
|
2015-02-02 16:51:16 +00:00
|
|
|
qreal padding() const;
|
|
|
|
void setPadding(qreal padding);
|
|
|
|
void resetPadding();
|
|
|
|
|
|
|
|
qreal topPadding() const;
|
|
|
|
void setTopPadding(qreal padding);
|
|
|
|
void resetTopPadding();
|
|
|
|
|
|
|
|
qreal leftPadding() const;
|
|
|
|
void setLeftPadding(qreal padding);
|
|
|
|
void resetLeftPadding();
|
|
|
|
|
|
|
|
qreal rightPadding() const;
|
|
|
|
void setRightPadding(qreal padding);
|
|
|
|
void resetRightPadding();
|
|
|
|
|
|
|
|
qreal bottomPadding() const;
|
|
|
|
void setBottomPadding(qreal padding);
|
|
|
|
void resetBottomPadding();
|
|
|
|
|
Invalidate text when application fonts are added or removed
We had multiple related issues due to application fonts being added
or removed during the application lifetime.
1. If a text had font family "foo" set, and this font did not
exist at the time, then loading "foo" at a later stage would not
update the text to use the correct font, since the result of
the previous request had been cached.
2. A variation of #1 was if the font "foo" was loaded by a FontLoader
in the scene and referred to by name in the text component. In this
case, there was a race condition, where the font lookup would sometimes
yield different results on the main thread and on the render thread,
and text would be garbled.
3. When a font was removed from the font database, then references to
it would remain in the caches (glyph cache + font cache) in the render
thread. With certain backends (DirectWrite, CoreText) this caused errors
or even crashes, as the cached font engines would be referring to data
that had been removed.
The work-around for #1 and #2 was merely to avoid hardcoding names for
fonts, but instead getting them from the FontLoader. This way, you can
avoid requesting the font family before it is available (and thus avoid
caching the wrong result). However, for #3 there is no known work-around.
This patch fixes all three (together with a smaller patch for qtbase) by
invalidating all text and related caches in Qt Quick when fonts are
either added or removed from the font database. This does add some
overhead if font loading happens during runtime, but the alternative is
broken behavior and dangling pointers.
This is done during the synchronization step. Before synchronization,
the font cache is flushed and all text components are marked for update,
so that fonts are re-requested against the new font database.
After synchronization, we delete all distance field glyph caches which
are not currently in use, to avoid having references to stale application
font data in the list.
[ChangeLog][Text] Fix multiple issues with usage of application fonts when
they are added or removed during the lifetime of the application.
Task-number: QTBUG-100697
Task-number: QDS-1142
Change-Id: Ib309e54e0ee97b6be6d2a7211964043fd51c9ec5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-18 11:57:01 +00:00
|
|
|
void invalidate() override;
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void textChanged();
|
|
|
|
void cursorPositionChanged();
|
2011-07-25 02:55:57 +00:00
|
|
|
void cursorRectangleChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void selectionStartChanged();
|
|
|
|
void selectionEndChanged();
|
|
|
|
void selectedTextChanged();
|
|
|
|
void accepted();
|
|
|
|
void acceptableInputChanged();
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 2) void editingFinished();
|
|
|
|
Q_REVISION(2, 9) void textEdited();
|
2012-02-20 07:18:20 +00:00
|
|
|
void colorChanged();
|
|
|
|
void selectionColorChanged();
|
|
|
|
void selectedTextColorChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void fontChanged(const QFont &font);
|
2016-04-07 09:22:33 +00:00
|
|
|
void horizontalAlignmentChanged(QQuickTextInput::HAlignment alignment);
|
|
|
|
void verticalAlignmentChanged(QQuickTextInput::VAlignment alignment);
|
2011-12-15 01:36:54 +00:00
|
|
|
void wrapModeChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void readOnlyChanged(bool isReadOnly);
|
|
|
|
void cursorVisibleChanged(bool isCursorVisible);
|
|
|
|
void cursorDelegateChanged();
|
2015-08-28 15:11:57 +00:00
|
|
|
void overwriteModeChanged(bool overwriteMode);
|
2011-04-27 12:13:26 +00:00
|
|
|
void maximumLengthChanged(int maximumLength);
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#if QT_CONFIG(validator)
|
2011-04-27 12:13:26 +00:00
|
|
|
void validatorChanged();
|
Fix build with -no-feature-validator
By removing property, getter, setter and notify signal for validator.
.../qmetatype.h: In instantiation of ‘constexpr bool
QtPrivate::checkTypeIsSuitableForMetaType() [with X = QValidator*]’:
.../qmetatype.h:2589:9: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* QtPrivate::qTryMetaTypeInterfaceForType()
[with Unique = void; TypeCompletePair =
QtPrivate::TypeAndForceComplete<QValidator*,
std::integral_constant<bool, true> >]’
.../qmetatype.h:2639:102: required from ‘constexpr const
QtPrivate::QMetaTypeInterface* const qt_metaTypeArray [72]<int,
QVariant, QQmlInstanceModel*, bool, int, int, QString, QString, QString,
QQmlComponent*, QQuickItem*, QQuickPopup*, bool, bool, bool, QString,
QValidator*, QFlags<Qt::InputMethodHint>, bool, bool, double, double,
QVariant, QString, bool, QQuickComboBox::ImplicitContentWidthPolicy,
QQuickComboBox, void, int, void, int, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void, void, void, void, void,
void, QString, int, int, const QString&, QFlags<Qt::MatchFlag>, int,
const QString&, QVariant, int, int, const QVariant&>’
.../moc_qquickcombobox_p.cpp:588:5: required from here
.../qmetatype.h:1181:55: error: static assertion failed: Pointer Meta
Types must either point to fully-defined types or be declared with
Q_DECLARE_OPAQUE_POINTER(T *)
Pick-to: 6.5
Change-Id: I0ee5ae9c84bc977571f39788299f1d84a7e582c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-16 05:21:43 +00:00
|
|
|
#endif
|
2011-04-27 12:13:26 +00:00
|
|
|
void inputMaskChanged(const QString &inputMask);
|
2016-04-07 09:22:33 +00:00
|
|
|
void echoModeChanged(QQuickTextInput::EchoMode echoMode);
|
2011-04-27 12:13:26 +00:00
|
|
|
void passwordCharacterChanged();
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 4) void passwordMaskDelayChanged(int delay);
|
2011-04-27 12:13:26 +00:00
|
|
|
void displayTextChanged();
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 7) void preeditTextChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void activeFocusOnPressChanged(bool activeFocusOnPress);
|
|
|
|
void autoScrollChanged(bool autoScroll);
|
|
|
|
void selectByMouseChanged(bool selectByMouse);
|
2016-04-07 09:22:33 +00:00
|
|
|
void mouseSelectionModeChanged(QQuickTextInput::SelectionMode mode);
|
2012-01-20 06:10:23 +00:00
|
|
|
void persistentSelectionChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void canPasteChanged();
|
2012-01-10 01:52:43 +00:00
|
|
|
void canUndoChanged();
|
|
|
|
void canRedoChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void inputMethodComposingChanged();
|
|
|
|
void effectiveHorizontalAlignmentChanged();
|
2012-02-07 01:57:42 +00:00
|
|
|
void contentSizeChanged();
|
2012-02-15 12:30:44 +00:00
|
|
|
void inputMethodHintsChanged();
|
2012-07-04 12:56:38 +00:00
|
|
|
void renderTypeChanged();
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 6) void paddingChanged();
|
|
|
|
Q_REVISION(2, 6) void topPaddingChanged();
|
|
|
|
Q_REVISION(2, 6) void leftPaddingChanged();
|
|
|
|
Q_REVISION(2, 6) void rightPaddingChanged();
|
|
|
|
Q_REVISION(2, 6) void bottomPaddingChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2014-10-16 14:57:08 +00:00
|
|
|
private:
|
|
|
|
void invalidateFontCaches();
|
2021-07-22 07:56:04 +00:00
|
|
|
void ensureActiveFocus(Qt::FocusReason reason);
|
2014-10-16 14:57:08 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
protected:
|
2018-02-21 09:41:54 +00:00
|
|
|
QQuickTextInput(QQuickTextInputPrivate &dd, QQuickItem *parent = nullptr);
|
TextInput/Field: selectByMouse default=true, but not on touchscreens
When you drag a finger across a TextInput or TextField, it should
not select text.
- your finger probably covers several characters, so you can't see where
you're selecting until afterwards
- if the item is in a Flickable, flicking by touch should be prioritized
- if flicking happens, the text cursor should not move; but to avoid
losing too much functionality, we allow it to move on release, if
the TextInput or TextField gets the release (i.e. if it still has
the exclusive grab)
- TextField's pressed, pressAndHold and released signals continue to
behave the same with touch as with mouse
So now we distinguish mouse events that are synthesized from non-mouse
devices and avoid mouse-like behaviors as described above, but there is
no behavior change if the event comes from an actual mouse or touchpad.
Since most users want selecting text by mouse to "just work", and an
actual mouse is precise enough to do so, and dragging a Flickable with
the mouse is unintuitive (since most UIs don't allow it and most mice
have wheels), selectByMouse now defaults to true, and has the stricter
meaning that its name implies. To select text on a touchscreen, the
end-user needs to rely on text-selection handles, which are provided on
touch-centric mobile platforms, and could also be implemented from
scratch if someone builds a custom text field using TextInput.
[ChangeLog][QtQuick][TextInput] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
using an import version < 6.4.
[ChangeLog][Controls][TextField] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
using an import version < 6.4.
Pick-to: 6.4
Task-number: QTBUG-10684
Task-number: QTBUG-38934
Task-number: QTBUG-101205
Change-Id: I6d3158dd48896a0bed37cbc0b2da01d313a499f8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-02-24 08:00:48 +00:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
|
|
|
|
void setOldSelectionDefault();
|
|
|
|
#endif
|
2015-06-18 19:38:57 +00:00
|
|
|
|
2020-03-23 15:07:09 +00:00
|
|
|
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
2014-08-09 14:18:01 +00:00
|
|
|
|
2017-09-20 18:57:39 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
|
|
|
void keyPressEvent(QKeyEvent* ev) override;
|
2016-11-16 13:22:36 +00:00
|
|
|
#if QT_CONFIG(im)
|
2017-09-20 18:57:39 +00:00
|
|
|
void inputMethodEvent(QInputMethodEvent *) override;
|
2012-11-22 17:47:45 +00:00
|
|
|
#endif
|
2017-09-20 18:57:39 +00:00
|
|
|
void mouseUngrabEvent() override;
|
|
|
|
bool event(QEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *event) override;
|
|
|
|
void focusInEvent(QFocusEvent *event) override;
|
|
|
|
void timerEvent(QTimerEvent *event) override;
|
|
|
|
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
|
|
|
|
void updatePolish() override;
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void selectAll();
|
|
|
|
void selectWord();
|
|
|
|
void select(int start, int end);
|
|
|
|
void deselect();
|
|
|
|
bool isRightToLeft(int start, int end);
|
2016-11-16 13:22:36 +00:00
|
|
|
#if QT_CONFIG(clipboard)
|
2011-04-27 12:13:26 +00:00
|
|
|
void cut();
|
|
|
|
void copy();
|
|
|
|
void paste();
|
|
|
|
#endif
|
2012-01-10 01:52:43 +00:00
|
|
|
void undo();
|
|
|
|
void redo();
|
2012-01-04 00:53:26 +00:00
|
|
|
void insert(int position, const QString &text);
|
|
|
|
void remove(int start, int end);
|
2020-01-16 12:42:11 +00:00
|
|
|
Q_REVISION(2, 4) void ensureVisible(int position);
|
|
|
|
Q_REVISION(2, 7) void clear();
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void selectionChanged();
|
|
|
|
void createCursor();
|
2014-05-16 12:35:23 +00:00
|
|
|
void updateCursorRectangle(bool scroll = true);
|
2011-04-27 12:13:26 +00:00
|
|
|
void q_canPasteChanged();
|
2012-01-09 11:41:36 +00:00
|
|
|
void q_updateAlignment();
|
2011-11-24 12:48:19 +00:00
|
|
|
void triggerPreprocess();
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2016-11-16 13:22:36 +00:00
|
|
|
#if QT_CONFIG(validator)
|
2012-06-21 06:44:30 +00:00
|
|
|
void q_validatorChanged();
|
|
|
|
#endif
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
private:
|
2012-05-04 06:07:32 +00:00
|
|
|
friend class QQuickTextUtil;
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_DECLARE_PRIVATE(QQuickTextInput)
|
2011-04-27 12:13:26 +00:00
|
|
|
};
|
|
|
|
|
TextInput/Field: selectByMouse default=true, but not on touchscreens
When you drag a finger across a TextInput or TextField, it should
not select text.
- your finger probably covers several characters, so you can't see where
you're selecting until afterwards
- if the item is in a Flickable, flicking by touch should be prioritized
- if flicking happens, the text cursor should not move; but to avoid
losing too much functionality, we allow it to move on release, if
the TextInput or TextField gets the release (i.e. if it still has
the exclusive grab)
- TextField's pressed, pressAndHold and released signals continue to
behave the same with touch as with mouse
So now we distinguish mouse events that are synthesized from non-mouse
devices and avoid mouse-like behaviors as described above, but there is
no behavior change if the event comes from an actual mouse or touchpad.
Since most users want selecting text by mouse to "just work", and an
actual mouse is precise enough to do so, and dragging a Flickable with
the mouse is unintuitive (since most UIs don't allow it and most mice
have wheels), selectByMouse now defaults to true, and has the stricter
meaning that its name implies. To select text on a touchscreen, the
end-user needs to rely on text-selection handles, which are provided on
touch-centric mobile platforms, and could also be implemented from
scratch if someone builds a custom text field using TextInput.
[ChangeLog][QtQuick][TextInput] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
using an import version < 6.4.
[ChangeLog][Controls][TextField] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
using an import version < 6.4.
Pick-to: 6.4
Task-number: QTBUG-10684
Task-number: QTBUG-38934
Task-number: QTBUG-101205
Change-Id: I6d3158dd48896a0bed37cbc0b2da01d313a499f8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-02-24 08:00:48 +00:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
|
|
|
|
class QQuickPre64TextInput : public QQuickTextInput {
|
|
|
|
Q_OBJECT
|
|
|
|
QML_NAMED_ELEMENT(TextInput)
|
|
|
|
QML_ADDED_IN_VERSION(2, 0)
|
|
|
|
QML_REMOVED_IN_VERSION(6, 4)
|
|
|
|
public:
|
|
|
|
QQuickPre64TextInput(QQuickItem *parent = nullptr);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
#endif // QQUICKTEXTINPUT_P_H
|