same shortcut on radcontextmenu and radmenu

1 Answer 19 Views
Menu
darin
Top achievements
Rank 1
Iron
Iron
darin asked on 01 Apr 2022, 12:39 PM

We use the same shortcut key in different places, where they can be in the general RadMenuItem but also on a menuitem in a RadContextMenu tied to a text box.

But, when i am focused on the text box and hit F12, it fires the radmenuitem F12 shortcut and never fires the contextmenu option. The ZIP file has the program that shows this.

Within windows using the standard menu and context menu, the context menu shortcut is fired and not the general menu shortcut. Windows seems to be treating it as you are on this field and there is a context menu with this shortcut - fire that event. Whereas Telerik seems to be looking at the general menu before the context menu.

Am i doing something wrong to get the context menu shortcut to fire and not the general menu shortcut?

darin
Top achievements
Rank 1
Iron
Iron
commented on 01 Apr 2022, 12:52 PM

Actually it seems almost random. In our program the F12 seems to be always firing when on a context menu even when it isn't a context menu tied to the textbox i am on.

Which is different than what my sample program shows, but still a little odd. I am still doing more testing on it. The F12 from the contextmenu is actually firing when i am on a text box that doesn't have any context menu on it.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 04 Apr 2022, 09:07 AM

Hi Darin,

Thank you for the provided project.

I have checked the project and you are in the right direction. We use a RadMessageFilter for handling shortcuts at a global level. In this case, there are two RadMenuItems with the same shortcut added (F12). Hence, when a shortcut combination is hit, the first RadMenuItem's shortcut is being processed and then further processing is not performed.

The possible solution that I can suggest in this situation is to use global shortcuts instead of defining a shortcut for each RadMenuItem. You can detect as many shortcut combinations as you wish with a single IShortcutProvider. Just add a new RadShortcut with the desired keys to the Shortcuts collection of your IShortcutProvider. Then, in the OnShortcut you can perform the desired action considering the ShortcutEventArgs.Shortcut and the currently focused control. A sample approach is demonstrated in the following help article: Assigning Global RadShortcuts

I have modified your project to demonstrate a possible solution. You can check the OnShortcut method in the custom MyShortcutProvider class. You can observe that I am checking if the RadTextBoxControl is focused. If yes, you can call the PerformClick() method of one of its RadContextMenu menu items. Keep in mind, that you will need to extend this approach so that it covers all your scenarios and different elements shortcuts.

Give this approach a try and let me know how it goes.

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Menu
Asked by
darin
Top achievements
Rank 1
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or