Add keyboard shortcuts 1 to 9 to quickly select palette colors

This commit is contained in:
jdescottes 2015-07-24 01:16:47 +02:00
parent 011b07c735
commit 9800d85cb7
3 changed files with 12 additions and 1 deletions

View File

@ -40,6 +40,7 @@
pskl.app.shortcutService.addShortcuts(['>', 'shift+>'], this.selectNextColor_.bind(this));
pskl.app.shortcutService.addShortcut('<', this.selectPreviousColor_.bind(this));
pskl.app.shortcutService.addShortcuts('123465789'.split(''), this.selectColorForKey_.bind(this));
this.fillPaletteList();
this.updateFromUserSettings();
@ -118,6 +119,12 @@
return currentIndex;
};
ns.PalettesListController.prototype.selectColorForKey_ = function (key) {
var index = parseInt(key, 10);
index = (index + 9) % 10;
this.selectColor_(index);
};
ns.PalettesListController.prototype.selectColor_ = function (index) {
var colors = this.getSelectedPaletteColors_();
var color = colors[index];

View File

@ -86,7 +86,8 @@
this.toDescriptor_('shift + N', 'Duplicate selected frame'),
this.toDescriptor_('shift + ?', 'Open/Close this popup'),
this.toDescriptor_('alt + P', 'Create a Palette'),
this.toDescriptor_('&lt;/&gt;', 'Select previous/next palette color'),
this.toDescriptor_('&lt;/&gt;', 'Select prev/next palette color'),
this.toDescriptor_('1 to 9', 'Select palette color at index'),
this.toDescriptor_('alt + O', 'Toggle Onion Skin'),
this.toDescriptor_('alt + L', 'Toggle Layer Preview')
];

View File

@ -27,6 +27,9 @@
if (keycode >= 48 && keycode <= 57) {
// key is 0-9
return (keycode - 48) + '';
} else if (keycode >= 96 && keycode <= 105) {
// key is numpad 0-9
return (keycode - 96) + '';
} else if (keycode >= 65 && keycode <= 90) {
// key is a-z, use base 36 to get the string representation
return (keycode - 65 + 10).toString(36);