Menu accelerator issue Topic is solved

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
Morat20
Knows some wx things
Knows some wx things
Posts: 35
Joined: Tue Jan 07, 2014 8:43 pm

Menu accelerator issue

Post by Morat20 » Tue Mar 19, 2019 10:17 pm

Using wxWidgets 2-9-5 (yes, I know it's old but it's what I have to work with), I seem to be running into the strangest issue with menu accelerators. Using the alt+ works, but not Ctrl+. Any menu item whose shortcut starts with "Alt" works correctly. None of the ones with "Ctrl" do. At this point, I'm certain I'm overlooking something incredibly obvious, but I can't figure it out.

file_menu = new wxMenu;
file_menu->Append(MENU_NEW, "New project\tCtrl+N");
file_menu->Append(MENU_OPEN, "Load project\tCtrl+L");
file_menu->Append(MENU_SaveInput, "Save input\tCtrl+S");
file_menu->Append(MENU_SaveInputAs,"Save input as...\tCtrl+I");
file_menu->AppendSeparator();
file_menu->Append(MENU_QUIT, "Exit\tAlt+F4");


Do I need an accelerator table for some reason?

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

Re: Menu accelerator issue

Post by doublemax » Tue Mar 19, 2019 10:30 pm

Which platform?
Did you check any of the samples that use keyboard shortcuts with "Ctrl"? E.g. the "stc" sample does.
Make a test with wx 3.x. If it works there, it means there was a bug in 2.9.5 that has been fixed by now.
Use the source, Luke!

Morat20
Knows some wx things
Knows some wx things
Posts: 35
Joined: Tue Jan 07, 2014 8:43 pm

Re: Menu accelerator issue

Post by Morat20 » Tue Mar 19, 2019 10:41 pm

doublemax wrote:
Tue Mar 19, 2019 10:30 pm
Which platform?
Did you check any of the samples that use keyboard shortcuts with "Ctrl"? E.g. the "stc" sample does.
Make a test with wx 3.x. If it works there, it means there was a bug in 2.9.5 that has been fixed by now.
Windows 7, and yes the samples work. I'm at a total loss.

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

Re: Menu accelerator issue

Post by doublemax » Tue Mar 19, 2019 11:34 pm

Windows 7, and yes the samples work. I'm at a total loss.
I can't think of any obvious reason either.

I assume the event handlers work when you invoke the menu items directly?
Do you have any key event handlers?

Either try to reproduce the issue in a minimal sample or try stripping down your code until you've isolated the issue.
Use the source, Luke!

Morat20
Knows some wx things
Knows some wx things
Posts: 35
Joined: Tue Jan 07, 2014 8:43 pm

Re: Menu accelerator issue

Post by Morat20 » Wed Mar 20, 2019 3:46 pm

doublemax wrote:
Tue Mar 19, 2019 11:34 pm
Windows 7, and yes the samples work. I'm at a total loss.
I can't think of any obvious reason either.

I assume the event handlers work when you invoke the menu items directly?
Do you have any key event handlers?

Either try to reproduce the issue in a minimal sample or try stripping down your code until you've isolated the issue.
Yes, direct invocation from the menu works. Replacing "Ctrl+L" with "Alt+L" works. It seems to be isolated to the use of the "Control" key, like something is catching any keyboard event that starts with "Ctrl".

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

Re: Menu accelerator issue

Post by ONEEYEMAN » Wed Mar 20, 2019 4:42 pm

Hi,
As doublemax suggested - do you have any keyboard events intercepted?
Thank you.

Morat20
Knows some wx things
Knows some wx things
Posts: 35
Joined: Tue Jan 07, 2014 8:43 pm

Re: Menu accelerator issue

Post by Morat20 » Wed Mar 20, 2019 4:49 pm

ONEEYEMAN wrote:
Wed Mar 20, 2019 4:42 pm
Hi,
As doublemax suggested - do you have any keyboard events intercepted?
Thank you.
I'm almost certain it is being interrupted, but I've been unable to find it so far. That's the only thing I can think of to describe the problem.

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

Re: Menu accelerator issue

Post by ONEEYEMAN » Wed Mar 20, 2019 5:00 pm

Hi,
Just try to search globally for 'wxKeyEvent'...

Thank you.

Morat20
Knows some wx things
Knows some wx things
Posts: 35
Joined: Tue Jan 07, 2014 8:43 pm

Re: Menu accelerator issue

Post by Morat20 » Wed Mar 20, 2019 6:58 pm

ONEEYEMAN wrote:
Wed Mar 20, 2019 5:00 pm
Hi,
Just try to search globally for 'wxKeyEvent'...

Thank you.
Thanks. That did it. Apparently a coworker wrote in a test function for some reason and didn't remove it or document it, and it was capturing the control events.

Thanks for the help all.

Post Reply