[SailfishDevel] TextField.forceActiveFocus() works only every second time

Michael Fuchs michfu at gmx.at
Thu Jun 22 10:43:01 UTC 2017


Hi Jerome,

Thanks a lot, this should do it.


Am 22.06.2017 um 12:30 schrieb jerome levreau:
> hi,
> I think this is an event loop issue, your event get in the middle or 
> other ui pending signal.
> Her a walk around using a timer :
> 
> Button {
>      x: Theme.horizontalPageMargin
>      text: qsTr("Hello Sailors")
>      onClicked: {
>          ta.text += "hello";
>          focus=false;
> 
>          bp_d.start();
>      }
> 
>      Timer {
>          id:bp_d
>          interval: 200
>          repeat: false
>          onTriggered: {
>              ta.forceActiveFocus();
>          }
>      }
> }
> 
> TextField {
>      id: ta
>      width: parent.width
>      text: "test"
>      focus: true
> }
> 
> 
> 
> 2017-06-22 11:09 GMT+02:00 Michael Fuchs <michfu at gmx.at 
> <mailto:michfu at gmx.at>>:
> 
>     Hi Guys,
> 
>     I got a textinput (e.g. TextField) in which the text gets
>     manipulated by pushing a button. After the manipulation the input
>     should get back focus. I'm trying it like this:
> 
>     Button {
>          x: Theme.horizontalPageMargin
>          text: qsTr("Hello Sailors")
>          onClicked: {
>              ta.text += "hello"
>              ta.forceActiveFocus()
>          }
>     }
>     TextField {
>          id: ta
>          text: "test"
>          focus: true
>     }
> 
>     But it only works every second time. How could I workaround this?
> 
>     Thanks,
>     Michael.
>     _______________________________________________
>     SailfishOS.org Devel mailing list
>     To unsubscribe, please send a mail to
>     devel-unsubscribe at lists.sailfishos.org
>     <mailto:devel-unsubscribe at lists.sailfishos.org>
> 
> 
> 
> 
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
> 


More information about the Devel mailing list