aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextinput.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Match QFont::ContextFontMerging with Qt Quick APIEskil Abrahamsen Blomfeldt21 hours1-0/+7
| | | | | | | | | | | | While we don't support all style strategy flags in Qt Quick, we do support selected ones as bools. QFont::ContextFontMerging is useful to be able to set per Text element, so it should be exposed through the QML APIs. Task-number: QTBUG-121131 Change-Id: If28a065aefc4e2043e830e31356b8bd98f6d4cd8 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QtQml: Add a wrapper builtin for QQmlV4Function*Ulf Hermann2024-04-121-1/+1
| | | | | | | | | This way qmltyperegistrar can recognize it and refrain from warning about it. Task-number: QTBUG-101143 Change-Id: I598140e7e90dbd3e27a78c26eff3d46f0fd3e989 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Android: fix handling of InputMethodQueryIvan Solovev2024-04-111-1/+7
| | | | | | | | | | | | | | | | | Somewhere between Qt 6.5.1 and dev (backported to 6.5.4) something has changed the behavior of QQuickItem::nextItemInFocusChain() or QQuickItem::activeFocusOnTab(). I could not figure out the patch to blame, because the actual code of these methods didn't change, but as a result the loop to determine the next focus item in QQuickTextInput::inputMethodQuery() was running forever. Fix it by explicitly checking if the element changes between the loop iterations, and if it does not, simply assing nullptr to it, acting as if no focus item was found in the chain. Fixes: QTBUG-123378 Pick-to: 6.7 6.5 Change-Id: I987f8ef2548cc116c2e69f5175d4af0bdb3ab3d0 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* TextField: Only enable paste action if clipboard has textWang Fei2024-02-201-1/+1
| | | | | | | | | | Regardless of whether the content of the system clipboard is empty, Paste Action was always enabled. Add a condition in canPaste that the clipboard has text, similar to what we do in Qt Widgets. Fixes: QTBUG-121594 Change-Id: I4b897c5ccea40229c4b8fc7d1d0da20540ed5ae1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace QSGTextNode::smooth with QSGTextNode::filteringEskil Abrahamsen Blomfeldt2024-02-151-1/+1
| | | | | | | | | | | | | The "smooth" property was intended to match the one in QQuickItem, which uses a less technical name (but also less precise). Since QSGTextNode is scenegraph API, it makes sense to expose the actual property of the texture instead of trying to mimic the vague name in QQuickItem. Pick-to: 6.7 Change-Id: I6fb2ac637a654e1df677bf95f43c28b0bc0661a1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Set default layout size policies for quick itemsSanthosh Kumar2024-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The quick items are initiliazed with default layout size policy. This size policy can be either Preferred or Fixed and it can vary depending on controls and its orientation. [ChangeLog][QtQuick][Item Behavior Changes] The QtQuick items now set their default size policy and it would be effective when used within QtQuick Layouts. The following types now behave differently by default when used in layouts: Button, CheckBox, ComboBox, Dial, DialogButtonBox, Frame, Flickable, GridView, GroupBox, HorizontalHeaderView, ListView, Page, Pane, PathView, ProgressBar, RadioButton, RangeSlider, RoundButton, ScrollBar, ScrollIndicator, ScrollView, Slider, SpinBox, SplitView, StackView, SwipeView, Switch, TabBar, TabButton, TableView, TextArea, TextEdit, TextField, TextInput, ToolButton, TreeView, Tumbler, VerticalHeaderView. Task-number: QTBUG-117597 Pick-to: 6.7 Change-Id: I41fe73a2e466e396f26604a14d1f15b8b42df338 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Add clear() function to QSGTextNode interfaceEskil Abrahamsen Blomfeldt2024-01-161-1/+1
| | | | | | | | | This was omitted from the API by accident, which makes the class a lot less convenient to use. Pick-to: 6.7 Change-Id: I648d5088725a8a5c1f1ec603c466656e4f318b0f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* TextArea/TextField: properly update placeholder text alignmentVladimir Belyavsky2024-01-091-18/+37
| | | | | | | | | | | | | | | | | | | | | | Placeholder text alignment depends on actual alignment of a parent control, e.g. TextArea or TextField. Thus, if the horizontal text alignment of the parent control is set explicitly, the placeholder text must have the same alignment. Otherwise, the placeholder text alignment should respect to the natural alignment of the text. In order to do this QQuickPlaceholderText is connected to effectiveHorizontalAlignmentChanged() signal of the parent control. The problem is that the signal may not be emitted when alignment is set explicitly after the component creation, so the placeholder text alignment will not be updated respectively. To solve this we need to make sure that the signal is forcibly emitted every time when the alignment is set explicitly. Fixes: QTBUG-120052 Pick-to: 6.7 6.6 6.5 Change-Id: Ib66a7a46d523777cc54ca6b6883d3fecc800dfb2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* qquicktext{edit,input}: Re-render when device pixel ratio changesKai Uwe Broulik2023-12-221-0/+20
| | | | | | | | | | | | Native rendering needs to be perfectly aligned to the pixel grid. When device pixel ratio changes, this can lead to blurry rendering. This was addressed for qquicktext in d870ea28 but not textedit/textinput. Pick-to: 6.7 6.6 6.5 Change-Id: I75d3172a047e73ba3e8e6cbcf4f5a9651d42c6b0 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Implement variable axes API in QMLEskil Abrahamsen Blomfeldt2023-12-051-0/+7
| | | | | | | | | [ChangeLog][QtQuick][Text] Added font.variableAxes property. Fixes: QTBUG-117836 Change-Id: Id35d346b8136d67054da404044ae80df8da61445 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Introduce a CurveRendering backend for textEskil Abrahamsen Blomfeldt2023-11-111-0/+8
| | | | | | | | | | | This moves the internals of the curve renderer out from Qt Quick Shapes and into a more centralized location in Qt Quick, so that we can use the same code to create a new text backend for rendering large scale text without artifacts. Change-Id: I3f7e6f7961c1bbe230fcb531c0ca028e038c1afd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Allow tapping to deselect in TextInput/TextField with pre-6.4 APIShawn Rutledge2023-11-071-1/+5
| | | | | | | | | Amends 650342de792e0ab37ce8bac8ccde21ab9b96b2c9 Fixes: QTBUG-116606 Pick-to: 6.5 6.6 Change-Id: I5c53559e0727c65a7d921a13f063ea2612cdcbca Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* qquicktextinput: use const method moreAnton Kudryavtsev2023-09-151-1/+1
| | | | | | | to avoid implicit detach Change-Id: I8b225b607698f468a35ba78948afb2e218430e96 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make text node scenegraph API publicEskil Abrahamsen Blomfeldt2023-09-011-9/+17
| | | | | | | | | | | | | | A lot of functionality is hidden underneath this, so exposing this API will make it possible to build custom text-based components for Qt Quick. [ChangeLog][Text] Added QSGTextNode and QQuickWindow::createTextNode() for creating scene graph nodes containing text. This can be useful when building custom Qt Quick items with text. Fixes: QTBUG-72773 Change-Id: I4810589cc28eb1cdfe91c9d8b66f4c6fe52a0c6a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Doc: add information about preeditText in text propertyBartlomiej Moskal2023-07-131-2/+11
| | | | | | | | | | | | | The documentation for the TextEdit::text and TextInput::text properties was missing information about preeditText. This may result in the expectation that text property will always contain all displayed text. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-109306 Change-Id: Ifa0b214238633a42e9772f796547f776a0d4251c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Doc: Fix documentation for font.features QML propertyTopi Reinio2023-07-051-59/+1
| | | | | | | | | | | | | | | | | | Add a link to font.features property to the 'font' QML value type reference. The property documentation is duplicated for multiple QML types; keep only a single instance in qquicktext.cpp, add snippet markers and \include the same documentation for the rest of the types. Fix code snippets to use \qml, \endqml commands. Fix \sa link to QFont::setFeature(). Pick-to: 6.6 Change-Id: Ieafd7691ab859a3ae509080e0ee24b3d00f276f9 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
* Add font.features API to match the one in QFontEskil Abrahamsen Blomfeldt2023-05-261-0/+65
| | | | | | | | | | | | For convenience, we make this a map from strings to integers and just ignore any entries which are not valid four-letter tags. [ChangeLog][QtQuick] Added font.features property for fine-grained customization of the shaping process. Change-Id: I4ceaed859c1641f7b5888b27fa5a5bd576b05547 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix word selection on touchTomi Korpipaa2023-04-181-1/+3
| | | | | | | | | | | | | The cursor position update on mouseReleaseEvent broke touch-and-hold word selection on touch devices. Now only do it if we don't have an active selection. Pick-to: 6.4 6.5 Fixes: QTBUG-111504 Fixes: QTBUG-110850 Change-Id: I5c63d8516d1eef3de10289c6d5c5b3d1d3e8623f Reviewed-by: Sami Varanka <sami.varanka@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* doc: Use \value rather than \li for enumeration values and constantsShawn Rutledge2023-03-281-82/+69
| | | | | | Pick-to: 6.2 6.5 Change-Id: Ica8354a53d0a5fb5dd1d8cd5f774dcdc56b6f99a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* quicktextinput: Update IM state after clearing selection with IM eventJarkko Koivikko2023-02-061-0/+1
| | | | | | | | | | | | | | | | | | | | Virtual keyboard uses quick text input as shadow input control attached on top of the keyboard when the actual input control is obscured by the keyboard. The shadow input is synchronized by the IM update events sent by the actual input control. When the user makes selection or moves cursor on the shadow input control, the change is synchronized to actual input control with input method event (QInputMethodEvent::Selection). This all works, except when there is a selection and the cursor is clicked. The expected outcome is that the selection is cleared, and it is, but it was not reported back to input method. Fix the issue by sending the update in case the selection is cleared. Pick-to: 6.5 6.4 Change-Id: Ieabc9ee97ad9fe6154d46f302314e3ebdfd10de2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix build with -no-feature-validatorTasuku Suzuki2023-01-171-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Android: Set EnterKeyNext as default type for TextInputBartlomiej Moskal2022-11-161-0/+23
| | | | | | | | | | | | | | | | | Behavior of EnterKey for virtual keyboard need to be changed for TextInput. Before this commit, ImeOption was set to IME_ACTION_DONE. Beacuse of that, setting any text in TextInput automatically accept QDialogs. That was annoying, when more than one QLineEdit need to be set. [ChangeLog][Quick][Android] EnterKey type is now changed from EnterKeyDefault to EnterKeyNext for virtual keyboard in TextInput. It is done only if the focus can be moved to QQuickItem below, so the activeFocusOnTab need to be set. Fixes: QTBUG-61652 Change-Id: Ib2faf78f4c85788498476c1e67e67d29d508cfea Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Propagate ShortcutOverride events up the parent chainVolker Hilsheimer2022-10-261-1/+4
| | | | | | | | | | | | | | | | | | | | | As with key events, ShortcutOverride events have to propagate up the parent chain so that parent items can override shortcuts with their own key handling. For that to work, items that implement shortcutOverride but don't handle the event must explicitly ignore it, as the events, like all input events are accepted by default. This revealed that QQuickTextEdit (via QQuickTextControl) and QQuickTextInput did not correclty ignore unhandled shortcut overrides, so fix those implementations. As a drive-by, explicitly capture the event parameter in the QML test's signal handler. Task-number: QTBUG-107703 Pick-to: 6.4 Change-Id: If38469c000733f53f5f936de38869b3b6f9fb07a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-57/+57
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Remove usages of "\js"Luca Di Sera2022-09-081-2/+2
| | | | | | | | | | | | | | | | | | | QDoc provides a "\js"/"\endjs", undocumented, unsupported, command pair to allow writers to write javascript code-blocks in the documentation. This command is part of a never-finalized javascript support for QDoc that is now being removed. To avoid breakages in the documentation, the usages of the command are now removed. The commands were replaced by a "\qml"/"\endqml" pair, that should be mostly equivalent, albeit some highlighting may be lost in the offline documentation. Task-number: QTBUG-106275 Change-Id: I765c72542ff46320332d1535fed823421514ed30 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Fix TextInput and TextField mouse/touch selection fallback behaviorShawn Rutledge2022-08-301-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We tried to make default behavior depend on the import version; but in Controls that does not work well, because the QQuickTextField instance is created in a style-specific QML file that does not use the same import version that the user is using. So we work around it by adding support for a Controls-specific env var to revert to pre-6.4 behavior. Adding the autotest proves that the fallback was broken a different way too: we didn't check selectByTouchDrag in all the necessary places. Amends 650342de792e0ab37ce8bac8ccde21ab9b96b2c9 [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 setting the environment variable QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR=old. Task-number: QTBUG-10684 Task-number: QTBUG-38934 Task-number: QTBUG-101205 Pick-to: 6.4 Change-Id: If1c1d6bd9c538f52022ae06d5252d178a1ae5a38 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix duplicate symbol lcTextInput build failure on static buildsLorn Potter2022-08-221-2/+2
| | | | | | | Fixes: QTBUG-105682 Pick-to: 6.4 Change-Id: I8c367403b64b5a976726fff210317b4212ea8695 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TextInput/Field: selectByMouse default=true, but not on touchscreensShawn Rutledge2022-07-161-12/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Doc: Fix linking issuesTopi Reinio2022-06-291-4/+3
| | | | | | | | | | | | | | | | | | | | | These linking issues have crept through as documentation testing in CI does not capture them. * Fix link to Qml CMake command reference. * Update link targets to the Qt Creator manual as they have changed; link to Qt Design Studio if applicable and remove links that are no longer available. * Fix linking to inherited properties for DragHandler, TableView, and TreeView. * Remove explicit linking to QSGTexture::commitTextureOperations() as that function is \internal. Pick-to: 6.4 Change-Id: I2c20fef8bc12e639374caac25ed358da887c35b3 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Doc: QQuickTextInput: Mark all readonly properties as suchIvan Tkachenko2022-06-011-3/+20
| | | | | | Pick-to: 6.3 6.2 5.15 Change-Id: I5fa12286ac594bafff89a56358bdda4051733e05 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Docs: Document textInput.acceptableInput as read onlyNicholas Bennett2022-05-041-0/+1
| | | | | | | | | Added \readonly to the qml property comment. Fixes: QTBUG-103224 Pick-to: 5.15 6.2 6.3 Change-Id: I42ddad6501700c586fe4154cd675d881a4686f8d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Invalidate text when application fonts are added or removedEskil Abrahamsen Blomfeldt2022-04-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Doc: Improve cursorPosition description in TextInput and TextEdit docsJaishree Vyas2022-03-291-1/+14
| | | | | | | | | | Fixes: QTBUG-97169 Pick-to: 5.15 6.2 6.3 6.3.0 Change-Id: I060be767dd980c489d8e5426d67f2e8b6d21e96c Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ivan Tkachenko <me@ratijas.tk> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* qquicktextinput: Allow adjusting selections through IMRichard Moe Gustavsen2021-11-021-5/+1
| | | | | | | | | | | | | | | | | | | | | Even if a TextInput is readOnly, it doesn't mean that Qt, or the application itself, cannot change the text. It's user input that is restricted. E.g a call to QQuickTextInput::setText() will change the text even if it's read-only. Moreover, QPA plugins (iOS) might adjust a selection in the input by letting the user drag on selection handles. And for this, IM events are also used. The QPA plugins will still need to (as before) check if the focus object has Qt::ImEnabled or Qt::ImReadOnly before changing the text. Therefore, this patch will remove the check before processing an IM event. Change-Id: Id2d9b54df3606108e3dafce34fdb2843668bd9c6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qquicktextinput: add ImReadOnlyRichard Moe Gustavsen2021-11-021-0/+2
| | | | | | | | | | | Follow up 99f08e98be, and add ImReadOnly to qquicktextinput as well. This will let the QPA backends be more precise when aiding text selection with selection handles etc. Task-number: QTBUG-91545 Task-number: QTBUG-75556 Change-Id: I85f43554f9a97d09ce47bbe6fe09753fd2fd5478 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTextInput: fix cursor positioning for QInputMethodEventIvan Solovev2021-10-141-1/+6
| | | | | | | | | | | On Android the cursor position was calculated incorrectly, which could results in rewriting the previously entered symbol. Change-Id: I7404979e098974d2e2cd8c91c6012cf5a52909b2 Fixes: QTBUG-94253 Pick-to: 6.2 5.15 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* qquicktextinput: fix formatGong Weia2021-09-131-2/+2
| | | | | | | add space between "){" Change-Id: Idcad221bb0643963ce44a9c1660e21b4053f225b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qquicktextinput: fix return nullptrGong Weia2021-09-131-1/+1
| | | | | | | fix return nullptr rather than 0 Change-Id: I6e3b15685e505c1921ae0ad96c43e99c9ccee54f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qquicktextinput: Clear pre-edit text after input method resetJarkko Koivikko2021-08-231-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | The QPlatformInputContext::reset() function does not allow any further input method events to be called. Therefore, clearing the pre-edit text is the sole responsibility of the text input control. This change modifies the QQuickTextInputPrivate::resetInputMethod() function and calls QQuickTextInputPrivate::cancelPreedit() instead of QInputMethod::reset() directly. The cancelPreedit() function will send a QInputMethodEvent which clears the IM state (in addition of calling QInputMethod::reset() function). Also, rename the QQuickTextInputPrivate::resetInputMethod() function to cancelInput, since it does not call inputMethod()->reset() directly. Fixes: QTBUG-95461 Pick-to: 5.15 6.1 6.2 Change-Id: I6ab3b9dbe71956af72656e2a25a05d79603b34ea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Inho Lee <inho.lee@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
* Pass the focus reason through to the control on mouse pressVolker Hilsheimer2021-07-231-4/+4
| | | | | | | | | | | | | | | | | Otherwise, a TextInput item will always receive OtherFocusReason when clicking into it. Add a test that simulates focus changes with mouse and keys, records the incoming focus events and verifies the correct focus reason is set in the event. Qt Quick provides no mechanism to access the focus reason from within QML (onActiveFocusChange only has a bool parameter, the focusReason property exists only in QtQuickControl). Task-number: QTBUG-75862 Pick-to: 6.2 6.1 5.15 Change-Id: Ifea95c7ef2ac88c6c8e8bbdc8d2dbe5205ff922e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickTextInput: update cursor rectangle after padding changedWang Chuan2021-04-161-0/+5
| | | | | | | | | | The position of cursor delegate needs to be updated when we change padding, otherwise it will be in a wrong position. Fixes: QTBUG-91867 Pick-to: 5.12 5.15 6.0 6.1 Change-Id: I89ca84fe893ebf517ab67890196eede14a4055d7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qquicktextinput: Fix validation for IM eventBartlomiej Moskal2021-02-191-1/+19
| | | | | | | | | | | | | | | | | If validation did not pass after text pre-editing is finished, it need to be roll back to state before pre-editing started. Before this change, if validation did not pass, text was always rolled back to previous state. In pre-editing text case, it means back to the state in which part of the text was removed (and later changed to pre-edited text). It may cause a situation of removing part of the text that was already validated Pick-to: 5.15 6.0 6.1 Fixes: QTBUG-90239 Change-Id: I3ec39e0f6b8a93d4e6fd190af30d4c80a0e495eb Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* qquicktextinput: Fix Undo history for IM eventBartlomiej Moskal2021-02-151-4/+6
| | | | | | | | | | | | | | | | | | Do not set m_cursor (cursor position) before calling removeSelectedText() in processInputMethodEvent(QInputMethodEvent *) method. Before this change, DeleteSelection command was added to history with new cursor position. If this command will be later rolled back, cursor position will not be set correctly. It should be set to position before handling the event. Pick-to: 5.15 6.0 6.1 Task-number: QTBUG-90239 Change-Id: Ib5e46d232e6b32f904e745da4f9e5bc03a58963f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* qquicktextinput: ensure we update IM when cursor changes positionRichard Moe Gustavsen2021-02-041-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Normally the cursor will change position inside a text input after receiving a touch or a keypress event. But it can also change position by sending it a QInputMethodEvent. But as it stood, we would in that case not inform the platform input context about it, which meant that the IM state in QQuickTextInput would be different from the IM state in QPA. A bug on iOS could be seen from this when dragging the cursor around using the magnifier glass. In that case QIOSTextResponder would move the cursor in QQuickTextInput using QInputMethodEvents. But since this would not be forwarded back to UITextInput, the result would be that if you e.g pushed backspace on the input panel, you would delete the character at the position the cursor had before the drag. This patch will ensure that we update platform IM state whenever the cursor changes position from QInputMethodEvents. Pick-to: 6.0 5.15 Fixes: QTBUG-72757 Change-Id: Ic39c60fbce982f80d014befddbb2d4439ddeea4f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Don't hide the inputMethod when finishing the editAndy Shaw2021-02-041-2/+0
| | | | | | | | | | | | | There is no reason to hide the inputMethod explicitly when finishing the editing. This will be taken care of for us by the platform plugin and will account for a situation where Qt Quick Controls 2 will check if the item had focus when it is in an popup being closed at this point too. Pick-to: 6.1 Change-Id: I687718ae9b4fabbf6456597a475507d2ec1a1f45 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTextInput: Store mask data in std::unique_ptrFabian Kosmale2020-11-241-4/+2
| | | | | | | | | This ensures that the memory is freed reliably Fixes: QTBUG-88807 Pick-to: 5.15 6.0 Change-Id: I841a5a2b226a69ce50975d95702a948857d1b54f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* qquicktextinput: compile with explicit QChar(int) constructorDavid Faure2020-11-091-11/+11
| | | | | Change-Id: I78fe89cd97b462299969d57cda099ce54fa8078a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use OpenType font weightsJonas Karlsson2020-08-281-1/+1
| | | | | | Task-number: QTBUG-42248 Change-Id: Ib26d4945307b630b054e270b3213e1c9ad0d5357 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Replace Qt's MidButton with MiddleButtonEdward Welbourne2020-07-221-1/+1
| | | | | | | | | | The latter has been the preferred name since Qt 4.7.0. Added a comment on where the old name is exposed to QML that it's only for backwards compatibility. Pick-to: 5.15 Change-Id: I2c5088d597dd7327cc5899d06afb180d0ec2893e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>