Opening menu using hotkey

Post Reply
User avatar
bjorntj
Posts: 216
Joined: 30 Jul 2010, 10:46

23 Apr 2016, 21:37

Is it possible to open the main menu using p:hotkey?


Regards,

BTJ
PrimeFaces 6.2 | Spring Boot 2/Undertow | Mojarra 2.3.4
Arch Linux, Firefox and Chromium

User avatar
aragorn
Posts: 3109
Joined: 29 Jun 2013, 12:38

25 Apr 2016, 13:05

I think you want to open or close main menu. Right? not submenu?

Which menu position are you using? Popup or Inline

User avatar
bjorntj
Posts: 216
Joined: 30 Jul 2010, 10:46

25 Apr 2016, 13:09

The main menu yes, the one defined in layoutmenu.xhtml

I am using popup...


BTJ
PrimeFaces 6.2 | Spring Boot 2/Undertow | Mojarra 2.3.4
Arch Linux, Firefox and Chromium

User avatar
aragorn
Posts: 3109
Joined: 29 Jun 2013, 12:38

25 Apr 2016, 13:12

For PopUp Menu, I think you can try the following steps;

Code: Select all

var Volt = {
  
    init: function() {
       ....
    },

    ....
    
    close: function(){  /* Please ADD */
        this.menuButton.removeClass('active-menu');
        this.menuWrapper.removeClass('active-menu');
    },
    
    open: function() { /* Please ADD */
        this.menuButton.addClass('active-menu');
        this.menuWrapper.addClass('active-menu');
    }
}
Then add p:hotkeys;

Code: Select all

<p:hotkey bind="up" handler="Volt.close();" /> /* Up arrow key*/
<p:hotkey bind="down" handler="Volt.open();" /> /* Down arrow key */
it works fine for me.

User avatar
bjorntj
Posts: 216
Joined: 30 Jul 2010, 10:46

25 Apr 2016, 13:15

Ok, will try this later on. thx... :)

BTJ
PrimeFaces 6.2 | Spring Boot 2/Undertow | Mojarra 2.3.4
Arch Linux, Firefox and Chromium

User avatar
aragorn
Posts: 3109
Joined: 29 Jun 2013, 12:38

25 Apr 2016, 13:18

Ok, thanks :)

Post Reply

Return to “Volt”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest