Clear Password Field with Scripting

I have a custom login popup that I've configured to close itself when it loses focus. I also successfully set up a script to clear the username field when the window closes with the following script executing on the window with the visionWindowClosed event handler. I attempted to do the same thing with the Password Field as shown below:

value = u''
system.gui.getParentWindow(event).getComponentForPath('Root Container.Login Container.Text Field').text = value
system.gui.getParentWindow(event).getComponentForPath('Root Container.Login Container.Password Field').text = value

The text in the Password Field did not clear when the window closed, but the Text Field successfully cleared. Can someone help me figure out why this script would work correctly with the Text Field component but not with the Password Field component?

What makes you believe it isn't working? Is it because the text is there when the window reopens? Any chance text was inadvertently saved in the password field in the designer, so that has become the default at open?

If the goal is to have the fields cleared when the window opens, perhaps use a binding to set the value to ''.

Beyond that, consider using the internalFrameClosing event handler since it happens earlier in the window's life cycle, and there's a higher probability that the component will still be running.

1 Like

I think if you just change the cache policy to Never on the window and make sure the fields are blank, every time it loads they'll start off blank and you won't need to mess with any of this.

2 Likes

Thanks for the information about the internalFrameClosing execution timing. That'll be helpful elsewhere in my project!

1 Like