mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Add keyboard shortcuts 1 to 9 to quickly select palette colors
This commit is contained in:
parent
011b07c735
commit
9800d85cb7
@ -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];
|
||||
|
@ -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_('</>', 'Select previous/next palette color'),
|
||||
this.toDescriptor_('</>', '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')
|
||||
];
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user