I have an AuiNotebook with arbitrary-many pages in it. Each one of
those pages has a button on it (which performs a search, but that's
irrelevant.) When creating the pages, I call each buttons'
SetDefault(), so that (hopefully) hitting Enter on the active page
will execute the right event. However, hitting Enter when *any* tab
has the focus will always execute the event associated with the button
on the tab that was added to the notebook *first*.
How should I make it so the correct button gets hit? Two ways that
I've thought of are un-setting the default buttons on the *other*
pages, and forgetting about setting default buttons and just
intercepting the key event from pressing Enter. I don't really like
either option, and I'm not even sure how to unset a default button.
I have an AuiNotebook with arbitrary-many pages in it. Each one of
those pages has a button on it (which performs a search, but that's
irrelevant.) When creating the pages, I call each buttons'
SetDefault(), so that (hopefully) hitting Enter on the active page
will execute the right event. However, hitting Enter when *any* tab
has the focus will always execute the event associated with the button
on the tab that was added to the notebook *first*.
Hmm... I thought that it would first look within the same panel for the default button to activate, but that code is pretty complex and I don't have time to decipher it at the moment. Is the button a child of the same panel as the widget that has the keyboard focus at the time that Enter is pressed?
How should I make it so the correct button gets hit? Two ways that
I've thought of are un-setting the default buttons on the *other*
pages, and forgetting about setting default buttons and just
intercepting the key event from pressing Enter. I don't really like
either option, and I'm not even sure how to unset a default button.
There isn't a way to do it since on some platforms the default button has different characteristics than other buttons so they can't be changed back and forth.
Any ideas?
Another (admittedly hacky) idea is to make your event handlers for the default buttons a little smarter and to redirect to the current page instead of handling it themselves. In other words, instead of this: