Does anyone know of an easy way to preserve focus when responding to EVT_CONTEXT_MENU events? I have a menu which contains some basic things like cut, copy and paste. When I reuse the same menu as a context menu, however, the focus is lost (or changed to the popup?) and so i can’t tell which component should be operated on.
So far the best solution I have found is to manually track the focus using either custom events or a global variable, but the problem with this is that I then need to listen for EVT_CONTEXT_MENU for every single field to make sure I have the right focus.
Does anyone have any suggestions for a better way around this?
I think that you should be able to get the origin of the EVT_CONTEXT_MENU event in the handler with evt.GetEventObject(). If so then you can use that to know which widget to apply the operation to. If not then please let us know platform, version and create a runnable sample that shows your problem.
···
On 9/4/11 7:15 AM, Keith Hughitt wrote:
Hi all,
Does anyone know of an easy way to preserve focus when responding to
EVT_CONTEXT_MENU events? I have a menu which contains some basic things
like cut, copy and paste. When I reuse the same menu as a context menu,
however, the focus is lost (or changed to the popup?) and so i can't
tell which component should be operated on.
So far the best solution I have found is to manually track the focus
using either custom events or a global variable, but the problem with
this is that I then need to listen for EVT_CONTEXT_MENU for every single
field to make sure I have the right focus.
Does anyone have any suggestions for a better way around this?