You could have a generic event handler that dispatches events from the main event loop, to the appropriate object(s) depending which one has the focus, is active, etc. Then, each object can block the event (most likely when it processed it), or propagate it to children / listeners.
Event dispatching rules in user interfaces can be tricky, you should read more about these. I don't know if there are tutorials or articles about it, but at least you can have a look at the source code of simple GUI libraries if you're really lost.