Currently I'm working on a pyGTK3 application for which I want to set the focus chain. When using the code below (simplified version) something interesting happens GTK focuses correctly on the first button but on tab nothing happens.
At first I thought this was caused by GTK not knowing the chain, but then I tried shift+tab which resulted in the last element of the chain get the focus which is correct. Yet another shift+tab doesn't move the focus away from the last button.
所以我认为我的代码有问题,我需要手动更新链顺序吗?或者我错过了什么?
class Screen(Gtk.Grid):
def __init__(self, parent, core, video_widget):
Gtk.Grid.__init__(self)
# adds the control buttons
self.controls = load_controls(self)
self.set_focus_chain((self.controls.play, self.controls.backward, self.controls.recording))
为了设置容器内元素的焦点链,需要首先将父级的焦点链设置到容器。从那里需要设置容器的焦点链。
因此代码需要如下:
# Points Gtk toward the container first
self.set_focus_chain([self.controls])
# Sets the focus chain inside the container
self.controls.set_focus_chain((self.controls.play, self.controls.backward, self.controls.recording, self.controls.end_inspection))
所以看来GTK只允许针对子代的焦点链,因此需要用户设置一条焦点链来将焦点链设置给孙子。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)