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,59 +402,62 @@ editor.constructor.prototype.listen=function () {
core.setLocalStorage('shortcut',shortcut); core.setLocalStorage('shortcut',shortcut);
return; return;
} }
// Ctrl+C, Ctrl+X, Ctrl+V var focusElement = document.activeElement;
if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) { if (!focusElement || focusElement.tagName.toLowerCase()=='body') {
copyedInfo = editor.copyFromPos(); // Ctrl+C, Ctrl+X, Ctrl+V
printf('该点事件已复制'); if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) {
return; e.preventDefault();
} copyedInfo = editor.copyFromPos();
if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) { printf('该点事件已复制');
copyedInfo = editor.copyFromPos();
editor.clearPos(true, null, function () {
printf('该点事件已剪切');
})
return;
}
if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) {
if (!copyedInfo) {
printe("没有复制的事件");
return; return;
} }
editor.pasteToPos(copyedInfo); if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) {
editor.updateMap(); e.preventDefault();
editor.file.saveFloorFile(function (err) { copyedInfo = editor.copyFromPos();
if (err) { editor.clearPos(true, null, function () {
printe(err); printf('该点事件已剪切');
throw(err) })
return;
}
if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) {
e.preventDefault();
if (!copyedInfo) {
printe("没有复制的事件");
return;
} }
;printf('粘贴事件成功'); editor.pasteToPos(copyedInfo);
editor.drawPosSelection(); editor.updateMap();
});
return;
}
// DELETE
if (e.keyCode == 46 && !selectBox.isSelected()) {
editor.clearPos(true);
return;
}
// ESC
if (e.keyCode == 27) {
if (selectBox.isSelected()) {
editor_mode.onmode('');
editor.file.saveFloorFile(function (err) { editor.file.saveFloorFile(function (err) {
if (err) { if (err) {
printe(err); printe(err);
throw(err) throw(err)
} }
;printf('地图保存成功'); ;printf('粘贴事件成功');
editor.drawPosSelection();
}); });
return;
}
// DELETE
if (e.keyCode == 46 && !selectBox.isSelected()) {
editor.clearPos(true);
return;
}
// ESC
if (e.keyCode == 27) {
if (selectBox.isSelected()) {
editor_mode.onmode('');
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('地图保存成功');
});
}
selectBox.isSelected(false);
editor.info = {};
return;
} }
selectBox.isSelected(false);
editor.info = {};
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;