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];