ctrl+C/X/V

This commit is contained in:
oc 2019-06-04 02:04:23 +08:00
parent f2796b1bd0
commit d0b8c2088f

View File

@ -349,7 +349,7 @@ editor.constructor.prototype.listen=function () {
return; return;
// 禁止快捷键的默认行为 // 禁止快捷键的默认行为
if (e.ctrlKey && [88, 67, 86, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) if (e.ctrlKey && [89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1)
e.preventDefault(); e.preventDefault();
if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1)
e.preventDefault(); e.preventDefault();
@ -402,13 +402,17 @@ editor.constructor.prototype.listen=function () {
core.setLocalStorage('shortcut',shortcut); core.setLocalStorage('shortcut',shortcut);
return; return;
} }
var focusElement = document.activeElement;
if (!focusElement || focusElement.tagName.toLowerCase()=='body') {
// Ctrl+C, Ctrl+X, Ctrl+V // Ctrl+C, Ctrl+X, Ctrl+V
if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) { if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) {
e.preventDefault();
copyedInfo = editor.copyFromPos(); copyedInfo = editor.copyFromPos();
printf('该点事件已复制'); printf('该点事件已复制');
return; return;
} }
if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) { if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) {
e.preventDefault();
copyedInfo = editor.copyFromPos(); copyedInfo = editor.copyFromPos();
editor.clearPos(true, null, function () { editor.clearPos(true, null, function () {
printf('该点事件已剪切'); printf('该点事件已剪切');
@ -416,6 +420,7 @@ editor.constructor.prototype.listen=function () {
return; return;
} }
if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) { if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) {
e.preventDefault();
if (!copyedInfo) { if (!copyedInfo) {
printe("没有复制的事件"); printe("没有复制的事件");
return; return;
@ -453,8 +458,6 @@ editor.constructor.prototype.listen=function () {
editor.info = {}; editor.info = {};
return; return;
} }
var focusElement = document.activeElement;
if (!focusElement || focusElement.tagName.toLowerCase()=='body') {
switch (e.keyCode) { switch (e.keyCode) {
// WASD // WASD
case 87: editor.moveViewport(0,-1); break; case 87: editor.moveViewport(0,-1); break;