gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.24k stars 82 forks source link

How to use `events` #966

Closed MGlolenstine closed 4 years ago

MGlolenstine commented 4 years ago

I've noticed, that many Widgets have an events parameter. I'm assuming that it's a mask, that allows you to filter the events that the view will or will not ignore. But now I don't know how to implement that. Does it have something to do with the connect macro?

sdroege commented 4 years ago

Yes it's a mask of the values here https://gtk-rs.org/docs/gdk/struct.EventMask.html to enable emission/handling of those windowing system events.

You get notified about those events via the connect_XXX_event() signals.

GuillaumeGomez commented 4 years ago

Closing then!

MGlolenstine commented 4 years ago

Ok, but how would I go about adding a BUTTON_RELEASED or even just clicked on a Label? Is that even possible, or would a workaround have to be used?

sdroege commented 4 years ago

You have to create a subclass of gtk::Widget and make use of the button_press_event() virtual method, for example. There are no signals for all events unfortunately.