Clearing a text field which has a float format?
- tpjctrl
- Posts:145
- Joined: Tue May 08, 2018 10:30 am
Clearing a text field which has a float format?
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.
- kilianvp
- Posts:443
- Joined: Fri Jan 16, 2015 10:29 am
Re: Clearing a text field which has a float format?
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?
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.
- kilianvp
- Posts:443
- Joined: Fri Jan 16, 2015 10:29 am
Re: Clearing a text field which has a float format?
This is not possible. The default value is always taken. For string the default value "" and for float 0.0 -> 0tpjctrl 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.
- ozangor
- Posts:44
- Joined: Thu Sep 22, 2011 2:57 pm
Re: Clearing a text field which has a float format?
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.
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?
Thanks ozangor!