mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:37:46 +02:00
Add cut to Create, and update shortcuts
This commit is contained in:
parent
65fdd16d90
commit
e0851c4807
2 changed files with 42 additions and 24 deletions
|
@ -1254,7 +1254,7 @@ function setupModelMenus() {
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: "Edit",
|
||||||
menuItemName: "Redo",
|
menuItemName: "Redo",
|
||||||
shortcutKey: 'Ctrl+Shift+Z',
|
shortcutKey: 'Ctrl+Y',
|
||||||
position: 1,
|
position: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2468,6 +2468,11 @@ function createEntities(entityProperties) {
|
||||||
return createdEntityIDs;
|
return createdEntityIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cutSelectedEntities() {
|
||||||
|
copySelectedEntities();
|
||||||
|
deleteSelectedEntities();
|
||||||
|
}
|
||||||
|
|
||||||
function copySelectedEntities() {
|
function copySelectedEntities() {
|
||||||
copyEntities(selectionManager.selections);
|
copyEntities(selectionManager.selections);
|
||||||
}
|
}
|
||||||
|
@ -2768,28 +2773,39 @@ var PopupMenu = function () {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function whenPressed(fn) {
|
||||||
|
return function(value) {
|
||||||
|
if (value > 0) {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function whenReleased(fn) {
|
||||||
|
return function(value) {
|
||||||
|
if (value === 0) {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var mapping = Controller.newMapping(CONTROLLER_MAPPING_NAME);
|
var mapping = Controller.newMapping(CONTROLLER_MAPPING_NAME);
|
||||||
mapping.from([Controller.Hardware.Keyboard.Delete]).when([!Controller.Hardware.Application.PlatformMac]).to(deleteKey);
|
mapping.from([Controller.Hardware.Keyboard.Delete]).when([!Controller.Hardware.Application.PlatformMac]).to(deleteKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.Backspace]).when([Controller.Hardware.Application.PlatformMac]).to(deleteKey);
|
mapping.from([Controller.Hardware.Keyboard.Backspace]).when([Controller.Hardware.Application.PlatformMac]).to(deleteKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.D]).when([Controller.Hardware.Keyboard.Control]).to(deselectKey);
|
|
||||||
mapping.from([Controller.Hardware.Keyboard.T]).to(toggleKey);
|
mapping.from([Controller.Hardware.Keyboard.T]).to(toggleKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.F]).to(focusKey);
|
mapping.from([Controller.Hardware.Keyboard.F]).to(focusKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.G]).to(gridKey);
|
mapping.from([Controller.Hardware.Keyboard.G]).to(gridKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.C]).when([Controller.Hardware.Keyboard.Control]).to(copyKey);
|
mapping.from([Controller.Hardware.Keyboard.X]).when([Controller.Hardware.Keyboard.Control]).to(whenReleased(cutSelectedEntities));
|
||||||
mapping.from([Controller.Hardware.Keyboard.V]).when([Controller.Hardware.Keyboard.Control]).to(pasteKey);
|
mapping.from([Controller.Hardware.Keyboard.C]).when([Controller.Hardware.Keyboard.Control]).to(whenReleased(copySelectedEntities));
|
||||||
|
mapping.from([Controller.Hardware.Keyboard.V]).when([Controller.Hardware.Keyboard.Control]).to(whenReleased(pasteEntities));
|
||||||
function copyKey(value) {
|
mapping.from([Controller.Hardware.Keyboard.D])
|
||||||
if (value > 0) {
|
.when([Controller.Hardware.Keyboard.Control])
|
||||||
copySelectedEntities();
|
.to(whenReleased(function() { SelectionManager.duplicateSelection() }));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pasteKey(value) {
|
|
||||||
if (value > 0) {
|
|
||||||
pasteEntities();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Bind undo to ctrl-shift-z to maintain backwards-compatibility
|
||||||
|
mapping.from([Controller.Hardware.Keyboard.Z])
|
||||||
|
.when([Controller.Hardware.Keyboard.Control, Controller.Hardware.Keyboard.Shift])
|
||||||
|
.to(whenPressed(function() { undoHistory.redo() }));
|
||||||
|
|
||||||
|
|
||||||
var propertyMenu = new PopupMenu();
|
var propertyMenu = new PopupMenu();
|
||||||
|
|
|
@ -98,6 +98,7 @@ CameraManager = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActionForKeyEvent(event) {
|
function getActionForKeyEvent(event) {
|
||||||
|
if (!event.isControl) {
|
||||||
var action = keyToActionMapping[event.key];
|
var action = keyToActionMapping[event.key];
|
||||||
if (action !== undefined) {
|
if (action !== undefined) {
|
||||||
if (event.isShifted) {
|
if (event.isShifted) {
|
||||||
|
@ -109,6 +110,7 @@ CameraManager = function() {
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue