I have a class that extends Gtk.Button
I have added a controller to the class that handle the button_pressed and button_released events
the buttons are in a Gtk.Grid object
when i middle click or right click the button label changes accordingly (and immediately)
but if i left click - the label changes and then does not respond to further middle or right click events
this is the bare bones of the class
using Gtk;
public class CalcButton : Gtk.Button {
// controller
private GestureClick button_pressed = new GestureClick ();
// properties
public int row { get; set; }
public int column { get; set; }
public int width { get; set;}
public int height { get; set; }
// constructor
public CalcButton () {
button_pressed.set_button (0);
button_pressed.pressed.connect (calc_button_pressed);
button_pressed.released.connect (calc_button_pressed);
this.add_controller (button_pressed);
}
// signal handler
private void calc_button_pressed (GestureClick gesture,
int n_press,
double x,
double y) {
switch (gesture.get_current_button ()) {
case 1:
this.label = "mouse left";
break;
case 2:
this.label = "middle";
break;
case 3:
this.label = "mouse right";
break;
default:
this.label = "something else";
break;
}
}
}
given that with Gtk 4 the move is away from add_events to controllers this seems odd behaviour
i’ve seen some mention that Gtk.Button has its own handlers for pressed and release - but these events are not exposed in Gtk.Button - only the clicked event is exposed
cheers,
G.