backbone-shortcuts icon indicating copy to clipboard operation
backbone-shortcuts copied to clipboard

Comma separated shortcuts doesn't works

Open nrako opened this issue 12 years ago • 8 comments

Assigning multiple shortcuts on a single line separated by comma as in keymaster.js doesn't works.

shortcuts: {
  'right, space': 'someMethod'
}

I understand you support the scope feature of keymaster.js https://github.com/madrobby/keymaster/#scopes which make it ugly to supports multiple shortcuts and a scope.

shortcuts: {
  // fulgy but could be nice to supports that for backwards compatibility
  'right, space myscope': 'notReallyNeat'
}

Maybe the above could be supported for backwards compatibility but a more clean declaration could be promoted :

shortcuts: {
  'right, space': {scope: 'myScope', method: 'someMethod'}
}

Let me know your thoughts and if you haven't time to implement it, I'll see if I have some for a fork-pull-request.

nrako avatar Aug 26 '12 17:08 nrako

Looks like @bry4n doesn't have time.

aeosynth avatar Sep 22 '12 05:09 aeosynth

I think it would be less funky to append the scope to the method:

shortcuts: {
  'right, space': 'someMethod myScope'
}

aeosynth avatar Sep 22 '12 05:09 aeosynth

@aeosynth yup it's obviously a neater solution.

I almost forgot about this issue, if @bry4n brings his insights I'll still be happy to make a pull-request.

nrako avatar Sep 22 '12 08:09 nrako

perhaps making a pull request would help @bry4n bring his insights

aeosynth avatar Sep 22 '12 08:09 aeosynth

Sorry! I have been busy. pull requests are welcome :+1: -- I can work on the fix this weekend.

how about this:

shortcuts: {
  "o, enter <myscope>": "someMethod"
}

That solution should be easier for me to update the regex pattern. https://github.com/bry4n/backbone-shortcuts/blob/master/src/backbone.shortcuts.coffee#L33

bry4n avatar Sep 24 '12 21:09 bry4n

i would find that very hard to parse - you have to check for a comma in the middle of a string

IMO my way is easier to read, since the value currently doesn't take a list

aeosynth avatar Sep 24 '12 21:09 aeosynth

The question is to decides if having the ability to have a different scope per event is desired. Or if it would rather introduce unnecessary redundancies. Or maybe both could be supported.

IMO and in my use cases it seems that it would introduce redundancies to have the scope defined with the event.

nrako avatar Sep 25 '12 07:09 nrako

+1

Is there a working accepted way to do this?

christiangenco avatar Jul 23 '13 00:07 christiangenco