[Solved] TextInput overwriteMode
-
wrote on 10 Jul 2012, 13:04 last edited by
Is there something like the QTextEdit overwriteMode ("overwriteMode-prop":http://qt-project.org/doc/qt-4.8/qtextedit.html#overwriteMode-prop) property for the Qml TextInput / TextEdit control?
I couldn't find anything similar in the documentation :(
-
wrote on 10 Jul 2012, 16:08 last edited by
I think that isn't anything similar but you can do a simple hack to get the insert behaviour:
@TextInput{
id: input
text: "ciao"
onTextChanged: {
var cursor = cursorPosition;
text = text.substring(0, cursorPosition)+text.substring(cursorPosition+1, text.length);
cursorPosition = cursor;
}
}@ -
wrote on 12 Jul 2012, 13:14 last edited by
Thank you! That's working fine.
But I still wonder why there is no overwrite mode property in the TextInput control.
-
wrote on 12 Jul 2012, 23:05 last edited by
I'd recommend adding a suggestion via http://bugreports.qt-project.org -- that way it has a better change of being looked into further and perhaps added in a future release.
Regards,
Michael -
wrote on 13 Jul 2012, 06:46 last edited by
Thank you for the suggestion!
"QTBUG-26513":https://bugreports.qt-project.org/browse/QTBUG-26513 -
wrote on 23 Jul 2012, 12:23 last edited by
I would also like the cursor to be different, depending on which mode is set.
So I was thinking about selecting the characters to overwrite them:@
TextInput
{
id: input
text: "ciao"
font.pixelSize: 20
onTextChanged:
{
select(cursorPosition, cursorPosition+1);
}
}
@This is working quite nice. But I don't know how to select the first character.
I tried this:
@
Component.onCompleted: select(0, 1)
@
The character was selected, but I couldn't enter anything anymore. Also the left/right keys were not working.The other problem are the left/right buttons. I would need to set the selection when they are pressed, too.
I tried this:
@
Keys.onPressed:
{
if(event.key == Qt.Key_Right)
{
select(cursorPosition, cursorPosition+1);
}
}
@
When the cursorPosition is 0 and I press the right arrow key, the cursor is on the second position (before the 'a'). When I press the right arrow key again, the cursor is behind the 'o' but nothing is selectedI also tried to set the cursorDelegate, but the Rectangle is shown on top of the text.