2

I have a BoxLayout with multiple actors in it. One of the actors is a St.Entry. I want this Entry to have keyboard-focus, so when the window is created, I can start typing right away.

I already found the "grab_key_focus()" method, but if I call that on my Entry it does nothing.

I am thankful for any help you can give me, since this has a really scarce documentation..

Algram
  • 94
  • 11

1 Answers1

1

The trick is

global.stage.set_key_focus(entry);

I found this by reading the source of an existing extension (Project Hamster extension), the exact line is here: https://github.com/projecthamster/shell-extension/blob/c99fb165430d12ff7e6e9b4c5a20f43eb56b810d/extension.js#L149

I use this extension and it has a text entry with initial focus which made me look in this extension for the functionality. How the author of that extension figured it out, I do not know.

Daniel Landau
  • 2,264
  • 2
  • 15
  • 19