Event source: menu vs accelerator

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
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Event source: menu vs accelerator

Post by gul_garak »

Hello!

Does anyone know if there's a way to determine the source of a wxCommandEvent that could have been either triggered from the menu itself or via an accelerator shortcut?

I know the Windows API has that info, but does it make it down to the wxWidgets events?

Thank you!

- Alejandro
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Event source: menu vs accelerator

Post by ONEEYEMAN »

Hi,
What problem you are trying to solve?
This would be a very ugly feature. The handler should work the same way independently of user action. Otherwise you user will complain about that.

Thank you.
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Re: Event source: menu vs accelerator

Post by gul_garak »

ONEEYEMAN wrote: Wed Mar 31, 2021 3:25 pm Hi,
What problem you are trying to solve?
This would be a very ugly feature. The handler should work the same way independently of user action. Otherwise you user will complain about that.

Thank you.
It's for handling the paste action. We'd like the paste position to follow the mouse cursor when using the shortcut (and not when using the menu). And I can't just look at the cursor in the handler because the menu could have been overlapping the document area.

Thank you!

- Alejandro
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Event source: menu vs accelerator

Post by doublemax »

The information is not accessible through the wxEvent class. I'd suggest to just use two different IDs.

Or - as a quick and dirty solution - you could check for the status of the CTRL key, which is probably still down when the keyboard shortcut was used.
https://docs.wxwidgets.org/trunk/group_ ... 41b71ce84f
Use the source, Luke!
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Re: Event source: menu vs accelerator

Post by gul_garak »

doublemax wrote: Wed Mar 31, 2021 5:44 pm Or - as a quick and dirty solution - you could check for the status of the CTRL key, which is probably still down when the keyboard shortcut was used.
https://docs.wxwidgets.org/trunk/group_ ... 41b71ce84f
This worked, thank you again!! :D

- Alejandro
Post Reply