mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Enhancement : #169 : Use several meta for shortcut
- can now use shift+ctrl+alt in shortcut definition - paste opaque for selection remapped to ctrl+shift+V
This commit is contained in:
parent
cf2c0e7045
commit
a060e32b15
@ -19,7 +19,7 @@
|
||||
$.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this));
|
||||
|
||||
pskl.app.shortcutService.addShortcut('ctrl+V', this.paste.bind(this));
|
||||
pskl.app.shortcutService.addShortcut('shift+V', this.pasteOpaqueOnly.bind(this));
|
||||
pskl.app.shortcutService.addShortcut('ctrl+shift+V', this.pasteOpaqueOnly.bind(this));
|
||||
pskl.app.shortcutService.addShortcut('ctrl+X', this.cut.bind(this));
|
||||
pskl.app.shortcutService.addShortcut('ctrl+C', this.copy.bind(this));
|
||||
pskl.app.shortcutService.addShortcut('del', this.erase.bind(this));
|
||||
|
@ -47,20 +47,31 @@
|
||||
};
|
||||
|
||||
ns.ShortcutService.prototype.parseKey_ = function (key) {
|
||||
var meta = 'normal';
|
||||
if (key.indexOf('ctrl+') === 0) {
|
||||
meta = 'ctrl';
|
||||
key = key.replace('ctrl+', '');
|
||||
} else if (key.indexOf('shift+') === 0) {
|
||||
meta = 'shift';
|
||||
key = key.replace('shift+', '');
|
||||
} else if (key.indexOf('alt+') === 0) {
|
||||
meta = 'alt';
|
||||
key = key.replace('alt+', '');
|
||||
}
|
||||
var meta = this.getMetaKey_({
|
||||
alt : key.indexOf('alt+') != -1,
|
||||
shift : key.indexOf('shift+') != -1,
|
||||
ctrl : key.indexOf('ctrl+') != -1
|
||||
});
|
||||
|
||||
var parts = key.split('+');
|
||||
key = parts[parts.length-1];
|
||||
return {meta : meta, key : key};
|
||||
};
|
||||
|
||||
ns.ShortcutService.prototype.getMetaKey_ = function (meta) {
|
||||
var keyBuffer = [];
|
||||
['alt', 'ctrl', 'shift'].forEach(function (metaKey) {
|
||||
if (meta[metaKey]) {
|
||||
keyBuffer.push(metaKey);
|
||||
}
|
||||
});
|
||||
|
||||
if (keyBuffer.length > 0) {
|
||||
return keyBuffer.join('+');
|
||||
} else {
|
||||
return 'normal';
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@ -73,16 +84,12 @@
|
||||
|
||||
var keyShortcuts = this.shortcuts_[charkey];
|
||||
if(keyShortcuts) {
|
||||
var cb;
|
||||
if (this.isCtrlKeyPressed_(evt)) {
|
||||
cb = keyShortcuts.ctrl;
|
||||
} else if (this.isShiftKeyPressed_(evt)) {
|
||||
cb = keyShortcuts.shift;
|
||||
} else if (this.isAltKeyPressed_(evt)) {
|
||||
cb = keyShortcuts.alt;
|
||||
} else {
|
||||
cb = keyShortcuts.normal;
|
||||
}
|
||||
var meta = this.getMetaKey_({
|
||||
alt : this.isAltKeyPressed_(evt),
|
||||
shift : this.isShiftKeyPressed_(evt),
|
||||
ctrl : this.isCtrlKeyPressed_(evt)
|
||||
});
|
||||
var cb = keyShortcuts[meta];
|
||||
|
||||
if(cb) {
|
||||
var bubble = cb(charkey);
|
||||
|
Loading…
Reference in New Issue
Block a user