Details
-
Sub-task
-
Resolution: Done
-
P3: Somewhat important
-
6aaf7b3c93687b857ff7cac0f2ad2ee510b2813b
Description
Needed for the text selection of right-to-left text and bi-directional text, and any other use case where the UI behavior depends on the reading direction of the text elements. The text selection handles should align differently on top of the text depending on the reading direction of the text under the selection end and selection start positions, but there is currently no way to query that from QML. In C++ side this can be achieved using method QString::isRightToLeft().
The API could be Qt::isRightToLeft(string) or TextEdit::isRightToLeft(posStart, posEnd).
TextEdit { SelectionHandle { id: startHandle x: editor.positionToRectangle(editor.selectionStart) + Qt.isRightToLeft(startCursorText) ? editor.width : 0 property string startCursorText: editor.text.substr(editor.selectionStart, editor.selectionStart+1) } SelectionHandle { id: endHandle x: editor.positionToRectangle(editor.selectionEnd) + Qt.isRightToLeft(endCursorText) ? 0 : -editor.width property string endCursorText: editor.text.substr(editor.selectionEnd, editor.selectionEnd+1) } }