Python code to automate return key press, tab key press, or mouse click

Hi all,

I feel like this should be a fairly simple line of python, but I can’t for the life of me figure it out.

In a nutshell, I am having users of my interface enter text into a text comp, and what I am looking for is a line of code to de-focus the text comp after they are done entering text.

As far as I can tell, there are any number of ways to remove focus from editing the text comp: you can press the return key, or the tab key, or mouse click off of the comp itself to de-focus. But I am looking for a line of code that I can add to a button press to automate this action.

If possible, I would like to avoid having to import an external python library.

Thanks for advising!!!

perhaps an easy fix is to set the Text COMP’s editmode parameter to “locked”.
Does that work for your case?

Hi Nettoyeur,

Thanks for your response!

That won’t work in this case, as I need the text to be editable by users and to update live, as it is plugging directly into a display where the text is live updating as they type.

if you set the parameter to locked and then immediately to editable again, the focus will be gone

Ah! Genius! That did not occur to me!

Thank you!!!