GNOME Bugzilla – Bug 695618
When dynamically adding to and removing a button from an EventBox, the Button won't receive mouse press (or any other) signals.
Last modified: 2017-09-04 21:07:43 UTC
Created attachment 238572 [details] A script to reproduce the bug. I've described the problem, including a code fragment that reproduces the error, in this SO question: http://stackoverflow.com/questions/15277594/gtk3-dynamically-adding-to-and-removing-a-button-from-an-eventbox-button-wont Even though in the description in the link above, I've used the python bindings, I think the problem is in Gtk in general, hence my filing this as a Gtk bug. For your convenience, the script to reproduce the bug is also added as an attachment of this bug report.
While removing the Fixed doesn't seem to solve this problem, having that there seems to get in the way of diagnosing it. Anyway, I can replicate this with the given test case - even after adding the missing return values to the handlers (assuming PyGI mirrors GLib in needing those). But I do have one thing to note: add a simple print to the start of your on_enter handler. Notice how it gets fired only once as you enter the window and hence the Fixed. But now hover over the Button. ::enter-notify-event is fired continuously! You clearly weren't expecting that, and it probably means the EventBox never gets to raise its window back, or similar. possibly somewhat relevant: Bug 556006
(In reply to Daniel Boles from comment #1) > But now hover over the Button. ::enter-notify-event is > fired continuously! ...as is ::leave-notify-event It seems that adding/removing the Fixed child causes the EventBox to receive a new enter/leave-notify-event, since you enter it when you remove the Button and fall through to the EventBox. Thus, you get stuck in a loop of adding/removing the Button to and from the Fixed, and it never gets to stick around long enough to receive input. I've not figured out exactly how to fix this yet, but it ought to give you enough to go on. Basically, you really need to avoid causing an infinite loop of events like this.
So, since we *want* the removal of a child widget to cause an enter-notify-event on the parent, the code is doing wrong things and confusing GTK+. Hopefully you can figure out a way to fix it, but I'm pretty certain it's not a bug in GTK+.