Hello I want to move from key-press-event/key-release-event to Gtk.EventControllerKey but can’t get any signal from it. What is wrong in this code?
from gi.repository import Gtk, GLib
window = Gtk.Window()
self.__controller = Gtk.EventControllerKey.new(window)
def _on_key_released(self, controller, val, code, state):
if __name__ == "__main__":
Window is a Widget subclass. See https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Widget.html#Gtk.Widget.add_events you can use to add the key-press and key-release events to the event mask of the object.
Same result… But I guess Gtk.Window already has this masks because connecting to “key-press-event” and “key-release-event” works.
Your code is correct, but GtkEventControllerKey is broken in GTK 3.
Thanks will wait for a fix or for GTK4
The signals exist and you can connect to them, but in some cases the object does not even try to emit them, such as when some “events” or flags are not set.
You can actually get the events mask of the window and check if the key-press and key-release events are set.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.