Also posted on github.com/gtk-rs/gtk4-rs/discussions
I created a push button using GestureClick:
Here is a snippet of the code:
// --snip--
// Add an action when the button is pressed
gesture_click.connect_pressed(
clone! (@weak push_button => move |gesture, _n_press, _x, _y| {
gesture.set_state(gtk::EventSequenceState::Claimed);
push_button.set_label("Release me!");
print!("Button pressed! \r");
let _ = std::io::stdout().flush();
}),
);
// Add an action when the button is released
gesture_click.connect_released(
clone! (@weak push_button => move |gesture, _n_press, _x, _y| {
gesture.set_state(gtk::EventSequenceState::Claimed);
push_button.set_label("Press me!");
print!("Button released!\r");
let _ = std::io::stdout().flush();
}),
);
// --snip--
But I can’t figure out how to get this to work with the space bar. Currently, this is what happens using the spacebar:
I also tried working with the spacebar using EventControllerKey, but I ran into the same situation as described here: