This is a migrated thread and some comments may be shown as answers.

How to focus on ContextMenu

1 Answer 240 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 2
Iron
Jack asked on 23 Oct 2018, 06:47 PM

I am building a custom widget with a kendo.ui.ContextMenu,

On Alt+M KeyUp event I open the menu using this.menu.open().

Following opening, I would like the menu to have the focus to navigate with arrow keys.

How can I achieve that?

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 25 Oct 2018, 09:49 AM
Hello Jack,

You should be able to achieve the desired result by using the jQuery focus() method on the ContextMenu wrapper as follows:
<script>
  $(document).keydown(function(e) {     
    if ((e.metaKey || e.altKey) && ( String.fromCharCode(e.which).toLowerCase() === 'm') ) {
      var contextMenu = $("#menu").getKendoContextMenu();
         
      contextMenu.open();
      contextMenu.wrapper.focus();
    }
  });
</script>

Refer to the following Dojo example, where the above code snippet is integrated. With it, the ContextMenu is being successfully opened after pressing "Alt+m". In addition to this, the wrapper of the widget is focused, thus allowing to navigate through the ContextMenu items with the arrow keys.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Menu
Asked by
Jack
Top achievements
Rank 2
Iron
Answers by
Dimitar
Telerik team
Share this question
or