TextInput and TextEdit cursor keeps blinking when item looses focus
-
I have two text input fields and want to switch from the first to the second if the user pressed the enter key.
Since i use a virtual keyboard which is not sending key events i have to resolve this with theonTextChangedhandler.
The switch itself is not the problem, but the cursor in the first field keeps blinking even if the item looses focus. So after i switch from first to second input, both fields show a blinking cursor but only the second input takes the key inputs.
It is a little bit confusing if you have 2 inputs and you dont know where you are typing now, so im looking for a solution to hide the cursor if the item has not the focus.My first item looks like this
TextInput { id: firstInput onTextChanged: { /* Check if enter key was pressed (charCode 10), remove it from the text, update the item value and send accepted event*/ if(text.length > 0 && text.charCodeAt(text.length-1) === 10) { var txt = text.substring(0,text.length-1); txt = txt.trim(); text = txt; console.log("emit accepted signal"); accepted(); } } onFocusChanged: { console.log("Focus changed to "+focus); } onCursorVisibleChanged: { console.log("Cursor visible changed to "+cursorVisible); } onAccepted: { console.log("Force focus to secondInput"); secondInput.forceActiveFocus(); } }And the debug output looks like
qml: emit accepted signal qml: Force focus to secondInput qml: Cursor visible changed to false qml: Focus changed to false qml: Cursor visible changed to trueYou can see that the cursor is set to false and than, after the item looses focus, it is set back to true. I tried to set the
cursorVisibleproperty in theonFocusChangedfunction to false, but it is ignored.So does anyone know how to fix this?