You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Event controller demo showcases button click with Ctrl key modifier by creating Gtk.EventControllerKey and tracking key state in global variable. This approach is at least bit quirky (eg. fails to track key state changes made off-focus) and seems like a bad practice (global variable, really?). I know it was meant to find show case for Gtk.EventControllerKey but I believe not teaching beginners (such as myself) bad practices is important. So maybe finding different show case is in order.
Proper technique for handling clicks and other events with key modifier is to use controller.get_current_event_state() in callback. For example like this.
defon_button_release(controller, clicks, x, y):
if (controller.get_current_event_state() &Gdk.ModifierType.CONTROL_MASK):
print("Ctrl was pressed")
else:
print("Ctrl was not pressed")
click=Gtk.GestureClick()
click.connect("released", on_button_release)
widget.add_controller(click)
The text was updated successfully, but these errors were encountered:
I have created this issue, because originally I have only sent PR which didn't get much attention. I don't know if it is normal time span for reaction or because issue was missing. Also if somebody wanted to propose better solution it is good to have issue to track all progress on this.
Event controller demo showcases button click with Ctrl key modifier by creating
Gtk.EventControllerKey
and tracking key state in global variable. This approach is at least bit quirky (eg. fails to track key state changes made off-focus) and seems like a bad practice (global variable, really?). I know it was meant to find show case forGtk.EventControllerKey
but I believe not teaching beginners (such as myself) bad practices is important. So maybe finding different show case is in order.Proper technique for handling clicks and other events with key modifier is to use
controller.get_current_event_state()
in callback. For example like this.The text was updated successfully, but these errors were encountered: