Error emptying formatted text field


I have a script in vision to set the text of a formatted text field component to empty and when the field is empty then some code lines should be executed.

Thats how I set the text of the formatted text field component to empty:


And this is how I check if the field is empty:

if id_to_filter=="":

My problem is that, this evaluation is always false because the text field is not empty but shows this instead:

How can I remove or avoid that space? I don't know where the space comes from. My code is really that simple.

How do you set your formatting? regex or formatted mask? I imagine those parameters will hold the answer to your question.

Validation mode is formatted mask:

I don't understand how this could be related to the problem.

The text will be the length of your formatted mask.

Ahn, I see. How can I avoid this then?

Add .strip() to the end of your scripted text property, so the whitespace is removed, and your code will work as intended:

if id_to_filter.strip()=="":

Thank you! Is there no possibility to also remove that whitespace from the field so that the cursor is set to the beginning of the field?

Adding this to your formatted text field's focusGained event handler would do that for you:


It won't remove the white space, but it will position your cursor where you want it.

Just tried it. Okay in that case it is better to let the cursor at the end

This doesn't work :weary:

Maybe someone from inductive automation could help?

Be more specific. Is the problem still cursor placement?

Sorry it is working:)
I had an error somewhere else

1 Like