看來當我打電話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更適合我的需求。謝謝你的回覆。 –