mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #290: Commit selection on ENTER
This commit is contained in:
parent
22797e5dc5
commit
01aa4629cc
@ -26,6 +26,7 @@
|
||||
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.CUT, this.cut.bind(this));
|
||||
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COPY, this.copy.bind(this));
|
||||
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.DELETE, this.onDeleteShortcut_.bind(this));
|
||||
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COMMIT, this.commit.bind(this));
|
||||
|
||||
$.subscribe(Events.TOOL_SELECTED, $.proxy(this.onToolSelected_, this));
|
||||
};
|
||||
@ -110,6 +111,19 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* If the currently selected tool is a selection tool, call dismissSelection handler on
|
||||
* the current tool instance.
|
||||
*/
|
||||
ns.SelectionManager.prototype.commit = function() {
|
||||
var tool = pskl.app.drawingController.currentToolBehavior;
|
||||
var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect;
|
||||
if (isSelectionTool) {
|
||||
var overlay = pskl.app.drawingController.overlayFrame;
|
||||
tool.dismissSelection(overlay);
|
||||
}
|
||||
};
|
||||
|
||||
ns.SelectionManager.prototype.replay = function (frame, replayData) {
|
||||
if (replayData.type === SELECTION_REPLAY.PASTE) {
|
||||
this.pastePixels_(frame, replayData.pixels);
|
||||
|
@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
var specialKeys = {
|
||||
191 : '?',
|
||||
8 : 'back',
|
||||
13 : 'enter',
|
||||
27 : 'esc',
|
||||
37 : 'left',
|
||||
38 : 'up',
|
||||
@ -20,6 +20,7 @@
|
||||
61 : '+',
|
||||
188 : '<',
|
||||
190 : '>',
|
||||
191 : '?',
|
||||
219 : '[',
|
||||
221 : ']'
|
||||
};
|
||||
|
@ -53,7 +53,18 @@
|
||||
* @return {Boolean} true if the shortcut can be updated
|
||||
*/
|
||||
ns.Shortcut.prototype.isEditable = function () {
|
||||
return this.getKeys().length < 2;
|
||||
if (this.getKeys().length === 0) {
|
||||
// No key defined: can be edited.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getKeys().length === 1) {
|
||||
// Only one key defined, can be edited if it is not using a forbidden key.
|
||||
return ns.Shortcuts.FORBIDDEN_KEYS.indexOf(this.getKeys()[0]) === -1;
|
||||
}
|
||||
|
||||
// More than one key, can't be edited.
|
||||
return false;
|
||||
};
|
||||
|
||||
ns.Shortcut.prototype.isCustom = function () {
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Or really custom shortcuts such as the 1-9 for color palette shorctus
|
||||
*/
|
||||
FORBIDDEN_KEYS : ['1', '2', '3', '4', '5', '6', '7', '8', '9', '?', 'shift+?',
|
||||
'del', 'back', 'ctrl+Y', 'ctrl+shift+Z'],
|
||||
'DEL', 'BACK', 'ENTER', 'ctrl+Y', 'ctrl+shift+Z'],
|
||||
|
||||
/**
|
||||
* Syntax : createShortcut(id, description, default key(s))
|
||||
@ -38,7 +38,8 @@
|
||||
CUT : createShortcut('selection-cut', 'Cut selection', 'ctrl+X'),
|
||||
COPY : createShortcut('selection-copy', 'Copy selection', 'ctrl+C'),
|
||||
PASTE : createShortcut('selection-paste', 'Paste selection', 'ctrl+V'),
|
||||
DELETE : createShortcut('selection-delete', 'Delete selection', ['del', 'back'])
|
||||
DELETE : createShortcut('selection-delete', 'Delete selection', ['DEL', 'BACK']),
|
||||
COMMIT : createShortcut('selection-commit', 'Commit selection', ['ENTER'])
|
||||
},
|
||||
|
||||
MISC : {
|
||||
|
@ -23,7 +23,8 @@
|
||||
this.tooltipDescriptors = [
|
||||
{description : 'Drag the selection to move it. You may switch to other layers and frames.'},
|
||||
{key : 'ctrl+c', description : 'Copy the selected area'},
|
||||
{key : 'ctrl+v', description : 'Paste the copied area'}
|
||||
{key : 'ctrl+v', description : 'Paste the copied area'},
|
||||
{key : 'shift', description : 'Hold to move the content'}
|
||||
];
|
||||
};
|
||||
|
||||
@ -52,6 +53,7 @@
|
||||
if (event.shiftKey && !this.isMovingContent_) {
|
||||
this.isMovingContent_ = true;
|
||||
$.publish(Events.SELECTION_CUT);
|
||||
this.drawSelectionOnOverlay_(overlay);
|
||||
}
|
||||
this.onSelectionMoveStart_(col, row, frame, overlay);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user