backbone-shortcuts
backbone-shortcuts copied to clipboard
Comma separated shortcuts doesn't works
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.
Looks like @bry4n doesn't have time.
I think it would be less funky to append the scope to the method:
shortcuts: {
'right, space': 'someMethod myScope'
}
@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.
perhaps making a pull request would help @bry4n bring his insights
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
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
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.
+1
Is there a working accepted way to do this?