Clearing a text field which has a float format?

Find and share HowTos to various installations / configurations!
Search

Post Reply
6 posts • Page 1 of 1
tpjctrl
Posts: 145
Joined: Tue May 08, 2018 10:30 am

Clearing a text field which has a float format?

Post by tpjctrl »

Anyone has any ideas on how to clear (ie. remove all shown text) a text field which is set to a float format? The usual textfield.text = ""; simply sticks a "0" in the textfield rather than wiping the contents. Format swap from float to string, then clear, then swap back to float also doesn't work as the textfield shows a "0" as soon as format goes back to float.

User avatar
kilianvp
Posts: 443
Joined: Fri Jan 16, 2015 10:29 am

Re: Clearing a text field which has a float format?

Post by kilianvp »

what should be in the text field? Completely empty?

tpjctrl
Posts: 145
Joined: Tue May 08, 2018 10:30 am

Re: Clearing a text field which has a float format?

Post by tpjctrl »

Yes that was the plan, the idea is to clear it completely (ie. remove any numbers from it) after the user enters a number and clicks a button to process an action. Not even sure if this is possible with float format text fields tbh.

User avatar
kilianvp
Posts: 443
Joined: Fri Jan 16, 2015 10:29 am

Re: Clearing a text field which has a float format?

Post by kilianvp »

tpjctrl wrote: Tue Jun 22, 2021 1:43 pm Yes that was the plan, the idea is to clear it completely (ie. remove any numbers from it) after the user enters a number and clicks a button to process an action. Not even sure if this is possible with float format text fields tbh.
This is not possible. The default value is always taken. For string the default value "" and for float 0.0 -> 0

ozangor
Posts: 44
Joined: Thu Sep 22, 2011 2:57 pm

Re: Clearing a text field which has a float format?

Post by ozangor »

Hi there,

I think updating the format in KeyboardFocusIn/Out events might be helpful for you.

Keep your textbox format as string, update the format back to float when KeyboardFocusIn is triggered (when typing cursor appears).

When your action button is clicked, you can set the format back to string and value to empty string.

tpjctrl
Posts: 145
Joined: Tue May 08, 2018 10:30 am

Re: Clearing a text field which has a float format?

Post by tpjctrl »

Thanks ozangor!

Post Reply
6 posts • Page 1 of 1