spacehammer icon indicating copy to clipboard operation
spacehammer copied to clipboard

Hotkeys to launch different modals

Open ihodes opened this issue 4 years ago • 4 comments

Is it possible to add to the below (basically, have multiple hotkeys which launch different modals)?

(local common-keys
        {:mods [:cmd :shift :alt :ctrl]
         :key :space
         :title "Apps"
         :items app-bindings})

(local config
       {:title "Main Menu"
        :items menu-items
        :keys  common-keys})

ihodes avatar Mar 25 '21 22:03 ihodes

Not currently supported, or even anticipated but could be feasible. I'm going to prioritize #72 for now and then can look into this possibly after. If you wish to make a PR feel free to give it a shot 🙂

jaidetree avatar Mar 27 '21 00:03 jaidetree

This shouldn't be difficult, and it makes sense to me.

A plan of attack:

  1. Have modal.activate-modal take a fsm as an arg. Probably default to the one locally defined in the module. (let [fsm (or _fsm fsm)])
  2. Take most of the functionality out of modal.init. Put it into some create-modal and make it return the fsm (+ cleanup func?)
  3. modal.init now basically does (set fsm (create-modal config))
  4. Whoever wants to define a separate modal menu system just creates one in their config and calls these functions manually e.g. (local mymodal (lib.modal.create-modal myfsm)) and binds a key to (fn [] (lib.modal.activate-modal mymodal))

Grazfather avatar Sep 16 '21 02:09 Grazfather

I don't think users should have to define custom state machines, more like the modal state machine should accept custom menu objects. I think there's an event on the modal state machine already like this that takes a submenu of the current modal to display that like when entering from Main -> Window.

With the advice system done, I should be able to make the required updates if needed to support this by the end of this weekend.

jaidetree avatar Sep 16 '21 04:09 jaidetree

@ihodes Out of curiosity, what makes that feature more desirable than pressing cmd+space a to access the apps menu? Especially if you press cmd+space it will show "Apps ..... a`, where as this proposal means the binding is hidden.

jaidetree avatar Sep 16 '21 13:09 jaidetree