Page 1 of 1

The delete key

Posted: Sat Dec 17, 2005 6:22 am
by icStatic
Hi,

Does anybody have any suggestions for how to get multiple event handlers to fire on a key press?

I have the Delete key bound to a menu item command (ie Edit->Delete) using a nice handy "\tDel" appended to the menu item, which when pressed deletes selected items on the main canvas of my program. This key enables/disables depending on whether there are objects selected (achieved using EVT_UPDATE_UI events).

The problem is I have a console (a wxTextCtrl) and various other components on the screen too and having this key bound to a menu item blocks the keystroke from reaching the other controls.

Any ideas how I can get the key press passed to the other controls as usual? If it fires the menu item at the same time this will be ok as I have a FindFocus call in there that compares the window handles to make it not trigger when the focus is one of the other controls.

Thanks,

Ian

Posted: Sat Dec 17, 2005 7:05 am
by delta
Why don't you just make your canvas handle the Del key as a keystroke? Then you can remove the association of the Del key with the menu item (the "\tDel"). You get a key stroke handler for the canvas and a menu item handler that do the same (e.g. both call a method that deltes the selected items).
This is how most programs I've see solve this situation.

Posted: Sat Dec 17, 2005 9:00 am
by icStatic
I would prefer not to have to do that. Most applications have the shortcut after their menu items. The other problem is that the canvas itself is not necessarily going to be in focus, there are other components which the user might be focused on, which is why I am after the exceptions for things like the console. I originally tried this method but I couldn't get it to work effectively, so I switched to the menu item shortcut.