[Solved] What is the input box property to check if the box has focus?

I have an input box and I want to check if the user has given it focus or not. What property do I compare against to check this? To check if the text changed I would do something similar to this below.

if propertyName == 'text':
    #code
    pass

But that doesn’t help me if I want to know whether the box is focused or not.

Thanks for any help.

I don’t know if there’s a property, but there are focusGained and focusLost event handlers. You can write scripts that execute when a specific event occurs. This could include writing a value to a custom property of the component.

1 Like

There is not a property event for that, @zacht is right, use the focusGained event handlers. Also, I find it handy to print the event.propertyName unfiltered which allows you to see what properties are changing and when they fire for debugging.

print event.propertyName

This will have to suffice. Thanks.