The delete key

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
icStatic
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Sep 08, 2005 6:41 pm
Location: Coventry, UK
Contact:

The delete key

Post by icStatic » Sat Dec 17, 2005 6:22 am

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

delta
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Dec 15, 2005 6:31 pm

Post by delta » Sat Dec 17, 2005 7:05 am

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.

icStatic
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Sep 08, 2005 6:41 pm
Location: Coventry, UK
Contact:

Post by icStatic » Sat Dec 17, 2005 9:00 am

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.

Post Reply