Hello all,
I am trying to gain focus on a component in perspective. My component is sitting inside a nested flex container.

I tried to supply this code into the startup event of the component itself:
self.focus()
did not work, then tried to write the focus command on the root container and the view itself did not work either. Usually this should work but I do not know what I am doing wrong here.
I don’t know how well applying focus works if a component is moving around. You MIGHT be running into a situation where the component starts up (and therefore fires off its onStartup Event), but the component is then moved around as the flex container grows/shrinks/flexes due to other components. Just out of curiosity, does it work if you wait for 3 seconds before invoking self.focus()
?
from time import sleep
sleep(3)
self.focus()
2 Likes
That fixed the issue. Thank you!
That's a different topic. Please don't hijack this one. Start a new thread.
1 Like
The fact that using sleep
is being identified as the solution makes me feel the need to ask for more votes on my suggestion of an onLoad
alternative to onStartup
:
A robust platform would never require using a hack like sleep
. I continue to use Timer
for things like this, but that's not much better than sleep
.
1 Like