你的gnome-shell-extension如何抓住重点?

时间:2015-04-26 17:48:58

标签: javascript linux gnome clutter gnome-shell-extensions

我有一个BoxLayout,里面有多个演员。其中一位演员是St.Entry。 我希望这个条目具有键盘焦点,所以当创建窗口时,我可以立即开始输入。

我已经找到了" grab_key_focus()"方法,但如果我在我的条目上调用它,它什么都不做。

我很感谢你能给我的任何帮助,因为这里有一份非常稀缺的文件......

1 个答案:

答案 0 :(得分: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.