Search code examples
menurichfaceskey-bindingshotkeys

Richfaces: menu key binding


I got a richface issue that rather looks very easy, but i can't find the answer. I want to acces a (dropdown)menu with keybindings. Once the menu has focus i can use the arrow buttons without a problem. I just cant get the 'focus' on my menu with a hotkey

XHTML:

<rich:dropDownMenu  
      binding="#{menuBarBean.menuBar}" 
      id="main-menu" 
      showEvent="mouseup" 
      onclick="showMenu();" 
      />


<rich:hotKey enabledInInput="true" key="ctrl+M" onkeyup="displayMenu()" preventDefault="true" />

JavaScript:

function displayMenu(){
  #{rich:component('main-menu')}.show();
  **// Do something that sets focus on the richface menu component**
}

In short: How to get the focus on

#{rich:component('main-menu')}

with:

<rich:hotKey />

Solution

  • jQuery has a .focus() method that focuses things:

    #{rich:component('main-menu')}.element.focus();