Closed Daniel15 closed 3 months ago
This is my fault - This was only available in Gtk3, and removed in Gtk4. Apparently I can use a custom widget and GtkGestureClick
to handle this. I'll try figure it out, or think of a new UI design that doesn't need this.
This works!
var gesture = GestureClick.New();
gesture.PropagationPhase = PropagationPhase.Capture;
gesture.OnPressed += (_, _) => Console.WriteLine("Pressed");
gesture.OnReleased += (_, _) => Console.WriteLine("Released");
_hello.AddController(gesture);
Hey, great you solved your problem. I could not have helped you very much as I'm not very familar with GTK either: I'm just the guy working on bindings for GObject based libraries😅.
Having some C# docs or sample projects to refer to for common problems would be very nice. So any help is welcome.
I've never written an app using Gtk, so let me know if I'm missing something obvious.
I want to have a button that does different things when pressed vs released. I found this Python code on StackOverflow: https://stackoverflow.com/a/19441817
With Gir.Core, I could add an OnClicked event handler for a Gtk.Button:
but I don't see
pressed
andreleased
events. It looks like the file containing the OnClicked event is a generated file (Button.Signals.Generated.cs
) so I'm not quite sure what to do.Thanks!