Page 1 of 1

Clearing a text field which has a float format?

Posted: Tue Jun 22, 2021 12:26 pm
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.

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

Posted: Tue Jun 22, 2021 12:48 pm
by kilianvp
what should be in the text field? Completely empty?

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

Posted: Tue Jun 22, 2021 1:43 pm
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.

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

Posted: Thu Jun 24, 2021 2:34 pm
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

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

Posted: Fri Jul 02, 2021 9:31 am
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.

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

Posted: Tue Sep 07, 2021 10:50 am
by tpjctrl
Thanks ozangor!