看来当我打电话Gdk.Seat.grab()在GJS我得到一个错误:是否可以在GJS中调用Gdk.Seat.grab()?
Gjs-WARNING **: JS ERROR: TypeError: Gdk.Seat.grab is not a function
这个函数和类是listed in the GJS Docs,但也许我打电话错了?如果我在Gdk.Seat.grab
上拨打typeof
,它会返回undefined
。这是不可能的,还是有另一种方式可以抓住焦点?
我的用例是收集用户的键绑定,我可以使用Gtk.CellRendererAccel
,但我不希望使用Gtk.TreeView
。该文件说约CellRenderers说:
These objects are used primarily by the GtkTreeView widget, though they aren’t tied to them in any specific way.
和...
The primary use of a GtkCellRenderer is for drawing a certain graphical elements on a cairo_t.
,这意味着我可以用它的TreeView之外,但没有提示如何。
啊,我应该意识到这一点。当我无法找到一个好的GJS例子时,我通常会回想起在C或Vala中找到一个例子(在这种情况下是gnome-control-center),但这实际上并不是我的特长,因此是错误的静态方法。我的用例是一个shell扩展的用户可配置键绑定,但TreeView路由中的CellRendererAccel更适合我的需求。谢谢你的回复。 –