Ultimately, I want to implement drag-and-drop manually, bypassing Gtk#'s drag-and-drop (because it does not support file dragging on Windows). To do that, I need to get the “mouse down” event on a GUI element (widget).
After creating .NET Core’s default GtkApplication, I added the following code to the auto-genearted _label
.
_label1.ButtonPressEvent += (o, args) =>
{
_label1.Text = "Mouse down";
};
But it did not get the event. I searched Google and found a similar Q&A on StackOverflow. I tried the suggested answers (both of them) like the following, but they did not work either.
Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask;
AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask));
_label1.Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask;
_label1.AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask));
Why doesn’t it work? I am attaching the source code and the auto-generated glade file. Ugh, it does not allow attaching text files. Attaching screen captures instead.