Open chang-zhao opened 1 year ago
Thank you for this tutorial. Until today I haven't found one for gtk4, so this is a blessing.
Currently I'm struggling with a simple question: how to detect a mouse button click in an Entry?
(I want to open a popup when left-click inside an Entry).
In GTK3, I did (in my entry class):
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self.connect("button-press-event", self.onClick)
but GTK4 doesn't have "button-press-event", right?
After some search, I managed to do something like this:
self.leftClick = Gtk.GestureClick() self.leftClick.set_button(1) self.leftClick.connect("pressed", self.onClick) self.add_controller(self.leftClick)
but the callback works only when I click on the entry's border, but not in the text field.
It would be nice to know how it works.
PS. Nevermind, it works with Gtk.EventControllerFocus.
Gtk.EventControllerFocus
Thank you for this tutorial. Until today I haven't found one for gtk4, so this is a blessing.
Currently I'm struggling with a simple question: how to detect a mouse button click in an Entry?
(I want to open a popup when left-click inside an Entry).
In GTK3, I did (in my entry class):
but GTK4 doesn't have "button-press-event", right?
After some search, I managed to do something like this:
but the callback works only when I click on the entry's border, but not in the text field.
It would be nice to know how it works.