How to get popup-menu or button-press-event event to fire on widget?

I have a GtkBox widget that I’d like to implement a context menu on, but I can’t get the popup-menu or button-press-event to fire on it. I set GDK_BUTTON_PRESS_MASK with gdk_window_set_events in a signal callback for the realize event of the box widget (which I confirmed fired), but I’m still not getting any signals. I also tried gtk_widget_set_events but that didn’t work. I confirmed with GTK inspector GDK_BUTTON_PRESS_MASK is set on the widget.

In GTK3, only widgets with an input window can respond to events.

GtkBox, like most containers, does not have an input window. If you want to deal with events you’ll need to put the GtkBox inside a GtkEventBox and connect to the eventbox’s signals.