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));
|
$.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this));
|
||||||
|
|
||||||
pskl.app.shortcutService.addShortcut('ctrl+V', this.paste.bind(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+X', this.cut.bind(this));
|
||||||
pskl.app.shortcutService.addShortcut('ctrl+C', this.copy.bind(this));
|
pskl.app.shortcutService.addShortcut('ctrl+C', this.copy.bind(this));
|
||||||
pskl.app.shortcutService.addShortcut('del', this.erase.bind(this));
|
pskl.app.shortcutService.addShortcut('del', this.erase.bind(this));
|
||||||
|
@ -47,20 +47,31 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.ShortcutService.prototype.parseKey_ = function (key) {
|
ns.ShortcutService.prototype.parseKey_ = function (key) {
|
||||||
var meta = 'normal';
|
var meta = this.getMetaKey_({
|
||||||
if (key.indexOf('ctrl+') === 0) {
|
alt : key.indexOf('alt+') != -1,
|
||||||
meta = 'ctrl';
|
shift : key.indexOf('shift+') != -1,
|
||||||
key = key.replace('ctrl+', '');
|
ctrl : key.indexOf('ctrl+') != -1
|
||||||
} else if (key.indexOf('shift+') === 0) {
|
});
|
||||||
meta = 'shift';
|
|
||||||
key = key.replace('shift+', '');
|
var parts = key.split('+');
|
||||||
} else if (key.indexOf('alt+') === 0) {
|
key = parts[parts.length-1];
|
||||||
meta = 'alt';
|
|
||||||
key = key.replace('alt+', '');
|
|
||||||
}
|
|
||||||
return {meta : meta, key : key};
|
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
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -73,16 +84,12 @@
|
|||||||
|
|
||||||
var keyShortcuts = this.shortcuts_[charkey];
|
var keyShortcuts = this.shortcuts_[charkey];
|
||||||
if(keyShortcuts) {
|
if(keyShortcuts) {
|
||||||
var cb;
|
var meta = this.getMetaKey_({
|
||||||
if (this.isCtrlKeyPressed_(evt)) {
|
alt : this.isAltKeyPressed_(evt),
|
||||||
cb = keyShortcuts.ctrl;
|
shift : this.isShiftKeyPressed_(evt),
|
||||||
} else if (this.isShiftKeyPressed_(evt)) {
|
ctrl : this.isCtrlKeyPressed_(evt)
|
||||||
cb = keyShortcuts.shift;
|
});
|
||||||
} else if (this.isAltKeyPressed_(evt)) {
|
var cb = keyShortcuts[meta];
|
||||||
cb = keyShortcuts.alt;
|
|
||||||
} else {
|
|
||||||
cb = keyShortcuts.normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cb) {
|
if(cb) {
|
||||||
var bubble = cb(charkey);
|
var bubble = cb(charkey);
|
||||||
|
Loading…
Reference in New Issue
Block a user