os-js / osjs-panels

OS.js Panels Module

Home Page:https://manual.os-js.org/v3/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Key binding to open application menu

RossComputerGuy opened this issue · comments

This feature would be useful for BlueLight and I'd like to get it added before I release 0.2.0-alpha.

I currently got this code:

    window.addEventListener('keydown',ev => {
      let opts = {
        ctrl: this.core.config('panel.menu.key').split('+').indexOf('Ctrl') > -1,
        shift: this.core.config('panel.menu.key').split('+').indexOf('Shift') > -1,
        alt: this.core.config('panel.menu.key').split('+').indexOf('Alt') > -1,
        meta: this.core.config('panel.menu.key').split('+').indexOf('Meta') > -1,
        key: this.core.config('panel.menu.key').split('+')[this.core.config('panel.menu.key').split('+').length-1]
      };
      if(ev.ctrlKey != opts.ctrl) return;
      if(ev.shiftKey != opts.shift) return;
      if(ev.altKey != opts.alt) return;
      if(ev.metaKey != opts.meta) return;
      if(ev.key != opts.key) return;
      const packages = this.core.make('osjs/packages').getPackages(m => (!m.type || m.type === 'application'));
      this.core.make('osjs/contextmenu').show({
        menu: makeTree(this.core, __, [].concat(packages)),
        callback: (item) => {
          const {name} = item.data || {};

          if (name) {
            this.core.run(name);
          }
        }
      });
    });

The only thing that's needed is to set the position and I'm thinking of using the mouse's position.

Publishing now

Re-opening because this will not work on Mac-s as it will interpolate the keypresses.

This code was removed in cef8ec4 and moved to os-js/osjs-client@c833b3c.

Adding to this, keycombos are defined globally in the client: https://github.com/os-js/osjs-client/blob/95e3b15e0b4779179606763c0bbc90958b5da420/src/config.js#L162

So this is now properly unit tested and hooked up to the internal event emitter.

Created a new issue that superseeds this one: os-js/osjs-client#70