Here’s a little puzzle for you all. Is there an elegant means for suppressing a key-up event when opening a dialog using a hot key?
Here’s the scenario:
- A menu entry opens a search dialog, and has a hot key assigned.
- If you click on the menu entry, a command event fires off the menu handler and the search dialog opens fine.
- When you press the hot key, it fires off the same menu handler, and the search dialog is opened.
- But, in the hot key case, releasing the key also generates an EVT_KEY_UP, which is then sent to the newly-opened search dialog.
My particular issue arises because I’m using the same key in the search dialog as a special key, so when #3 occurs, I get an extra key event that I don’t want to see (but only that first time).
I’ve got an ugly hack implemented where the menu event handler detects if it was entered due to a click or a hot key event and tells the search dialog about this so it can act accordingly, but “ugly hack” doesn’t make me happy and I was wondering if anyone had a simpler or at least less ugly way to handle this.