Right now I'm developing an GTK+ application within Python3. In part of application I need long press signal and for that reason I've used the Gtk.GestureLongPress class as below:
longPress = Gtk.GestureLongPress.new(widget)
longPress.connect("pressed", longPressFunction)
longPress.connect("cancelled", normalPressFuntion)
finally after running the application, I would like to test the functionality. however, I don't have any touch device to test touch action and that's why I'm using GtkInspector. In GtkInspector I have enabled Simulate touchscreen as below, but still no action happening. any suggestions? what did I wrong or what should I do to get it worked? enter image description here
Probably this is just a memory management issue. If the longPress object goes out of scope it will be destroyed because widget has no reference on it. So you can make longPress a class member to prevent longPress from going out of scope:
self.buttonLongPress = Gtk.GestureLongPress.new(self.button)
self.buttonLongPress.connect("pressed", longPressFunction)
self.buttonLongPress.connect("cancelled", normalPressFuntion)
Note: you have to simulate the touch screen only if you use:
self.buttonLongPress.set_touch_only(True)