mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Make shortcuts work in edit windows
This commit is contained in:
parent
d7dd593a97
commit
e890228fc7
6 changed files with 137 additions and 73 deletions
|
@ -113,7 +113,6 @@ selectionManager.addEventListener(function () {
|
|||
entityIconOverlayManager.updatePositions();
|
||||
});
|
||||
|
||||
var KEY_P = 80; //Key code for letter p used for Parenting hotkey.
|
||||
var DEGREES_TO_RADIANS = Math.PI / 180.0;
|
||||
var RADIANS_TO_DEGREES = 180.0 / Math.PI;
|
||||
|
||||
|
@ -1964,14 +1963,6 @@ var keyReleaseEvent = function (event) {
|
|||
if (isActive) {
|
||||
cameraManager.keyReleaseEvent(event);
|
||||
}
|
||||
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
||||
if (event.key === KEY_P && event.isControl && !event.isAutoRepeat) {
|
||||
if (event.isShifted) {
|
||||
unparentSelectedEntities();
|
||||
} else {
|
||||
parentSelectedEntities();
|
||||
}
|
||||
}
|
||||
};
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
|
@ -2365,10 +2356,6 @@ var PropertiesTool = function (opts) {
|
|||
}
|
||||
pushCommandForSelections();
|
||||
selectionManager._update(false, this);
|
||||
} else if (data.type === 'parent') {
|
||||
parentSelectedEntities();
|
||||
} else if (data.type === 'unparent') {
|
||||
unparentSelectedEntities();
|
||||
} else if (data.type === 'saveUserData' || data.type === 'saveMaterialData') {
|
||||
//the event bridge and json parsing handle our avatar id string differently.
|
||||
var actualID = data.id.split('"')[1];
|
||||
|
@ -2681,9 +2668,14 @@ function whenReleased(fn) {
|
|||
};
|
||||
}
|
||||
|
||||
var isOnMacPlatform = Controller.getValue(Controller.Hardware.Application.PlatformMac);
|
||||
|
||||
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.Backspace]).when([Controller.Hardware.Application.PlatformMac]).to(deleteKey);
|
||||
if (isOnMacPlatform) {
|
||||
mapping.from([Controller.Hardware.Keyboard.Backspace]).to(deleteKey);
|
||||
} else {
|
||||
mapping.from([Controller.Hardware.Keyboard.Delete]).to(deleteKey);
|
||||
}
|
||||
mapping.from([Controller.Hardware.Keyboard.T]).to(toggleKey);
|
||||
mapping.from([Controller.Hardware.Keyboard.F]).to(focusKey);
|
||||
mapping.from([Controller.Hardware.Keyboard.G]).to(gridKey);
|
||||
|
@ -2706,6 +2698,51 @@ mapping.from([Controller.Hardware.Keyboard.Z])
|
|||
.to(whenPressed(function() { undoHistory.redo() }));
|
||||
|
||||
|
||||
mapping.from([Controller.Hardware.Keyboard.P])
|
||||
.when([Controller.Hardware.Keyboard.Control, Controller.Hardware.Keyboard.Shift])
|
||||
.to(whenReleased(function() { unparentSelectedEntities(); }));
|
||||
|
||||
mapping.from([Controller.Hardware.Keyboard.P])
|
||||
.when([Controller.Hardware.Keyboard.Control, !Controller.Hardware.Keyboard.Shift])
|
||||
.to(whenReleased(function() { parentSelectedEntities(); }));
|
||||
|
||||
function keyUpEventFromUIWindow(keyUpEvent) {
|
||||
var WANT_DEBUG_MISSING_SHORTCUTS = false;
|
||||
|
||||
var pressedValue = 0.0;
|
||||
// Note: For some reason the keyboardEvent for delete does not show a code, using key instead:
|
||||
if ((!isOnMacPlatform && keyUpEvent.key === "Delete") || (isOnMacPlatform && keyUpEvent.code === "Backspace")) {
|
||||
deleteKey(pressedValue);
|
||||
} else if (keyUpEvent.code === "KeyT") {
|
||||
toggleKey(pressedValue);
|
||||
} else if (keyUpEvent.code === "KeyF") {
|
||||
focusKey(pressedValue);
|
||||
} else if (keyUpEvent.code === "KeyG") {
|
||||
gridKey(pressedValue);
|
||||
} else if (keyUpEvent.ctrlKey && keyUpEvent.code === "KeyX") {
|
||||
selectionManager.cutSelectedEntities();
|
||||
} else if (keyUpEvent.ctrlKey && keyUpEvent.code === "KeyC") {
|
||||
selectionManager.copySelectedEntities();
|
||||
} else if (keyUpEvent.ctrlKey && keyUpEvent.code === "KeyV") {
|
||||
selectionManager.pasteEntities();
|
||||
} else if (keyUpEvent.ctrlKey && keyUpEvent.code === "KeyD") {
|
||||
selectionManager.duplicateSelection();
|
||||
} else if (keyUpEvent.ctrlKey && !keyUpEvent.shiftKey && keyUpEvent.code === "KeyZ") {
|
||||
undoHistory.undo();
|
||||
} else if (keyUpEvent.ctrlKey && !keyUpEvent.shiftKey && keyUpEvent.code === "KeyP") {
|
||||
parentSelectedEntities();
|
||||
} else if (keyUpEvent.ctrlKey && keyUpEvent.shiftKey && keyUpEvent.code === "KeyP") {
|
||||
unparentSelectedEntities();
|
||||
} else if (
|
||||
(keyUpEvent.ctrlKey && keyUpEvent.shiftKey && keyUpEvent.code === "KeyZ") ||
|
||||
(keyUpEvent.ctrlKey && keyUpEvent.code === "KeyY")) {
|
||||
|
||||
undoHistory.redo();
|
||||
} else if (WANT_DEBUG_MISSING_SHORTCUTS) {
|
||||
console.warn("unhandled key event: " + JSON.stringify(keyUpEvent))
|
||||
}
|
||||
}
|
||||
|
||||
var propertyMenu = new PopupMenu();
|
||||
|
||||
propertyMenu.onSelectMenuItem = function (name) {
|
||||
|
@ -2719,21 +2756,6 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace");
|
|||
|
||||
var propertiesTool = new PropertiesTool();
|
||||
|
||||
entityListTool.webView.webEventReceived.connect(function(data) {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch(e) {
|
||||
print("edit.js: Error parsing JSON");
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === 'parent') {
|
||||
parentSelectedEntities();
|
||||
} else if (data.type === 'unparent') {
|
||||
unparentSelectedEntities();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
selectionDisplay.onSpaceModeChange = function(spaceMode) {
|
||||
entityListTool.setSpaceMode(spaceMode);
|
||||
|
|
|
@ -21,8 +21,6 @@ const MAX_LENGTH_RADIUS = 9;
|
|||
const MINIMUM_COLUMN_WIDTH = 24;
|
||||
const SCROLLBAR_WIDTH = 20;
|
||||
const RESIZER_WIDTH = 10;
|
||||
const DELETE = 46; // Key code for the delete key.
|
||||
const KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
||||
|
||||
const COLUMNS = {
|
||||
type: {
|
||||
|
@ -1115,21 +1113,46 @@ function loaded() {
|
|||
}
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", function (keyDownEvent) {
|
||||
if (keyDownEvent.target.nodeName === "INPUT") {
|
||||
document.addEventListener("keyup", function (keyUpEvent) {
|
||||
if (keyUpEvent.target.nodeName === "INPUT") {
|
||||
return;
|
||||
}
|
||||
let keyCode = keyDownEvent.keyCode;
|
||||
if (keyCode === DELETE) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
||||
}
|
||||
if (keyDownEvent.keyCode === KEY_P && keyDownEvent.ctrlKey) {
|
||||
if (keyDownEvent.shiftKey) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
|
||||
if (keyUpEvent.ctrlKey && keyUpEvent.code === "KeyA") {
|
||||
let visibleEntityIDs = visibleEntities.map(visibleEntity => visibleEntity.id);
|
||||
let selectionIncludesAllVisibleEntityIDs = visibleEntityIDs.every(visibleEntityID => {
|
||||
return selectedEntities.includes(visibleEntityID);
|
||||
});
|
||||
|
||||
let selection = [];
|
||||
|
||||
if (!selectionIncludesAllVisibleEntityIDs) {
|
||||
selection = visibleEntityIDs;
|
||||
}
|
||||
|
||||
updateSelectedEntities(selection);
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "selectionUpdate",
|
||||
focus: false,
|
||||
entityIds: selection,
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let {code, key, altKey, ctrlKey, shiftKey} = keyUpEvent;
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: 'keyUpEvent',
|
||||
keyUpEvent: {
|
||||
code,
|
||||
key,
|
||||
altKey,
|
||||
ctrlKey,
|
||||
shiftKey
|
||||
}
|
||||
}));
|
||||
}, false);
|
||||
|
||||
if (window.EventBridge !== undefined) {
|
||||
|
|
|
@ -1352,8 +1352,6 @@ const COLOR_MIN = 0;
|
|||
const COLOR_MAX = 255;
|
||||
const COLOR_STEP = 1;
|
||||
|
||||
const KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
||||
|
||||
const MATERIAL_PREFIX_STRING = "mat::";
|
||||
|
||||
const PENDING_SCRIPT_STATUS = "[ Fetching status ]";
|
||||
|
@ -3494,16 +3492,23 @@ function loaded() {
|
|||
el.parentNode.removeChild(el);
|
||||
elDropdowns = document.getElementsByTagName("select");
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", function (keyDown) {
|
||||
if (keyDown.keyCode === KEY_P && keyDown.ctrlKey) {
|
||||
if (keyDown.shiftKey) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
}
|
||||
|
||||
document.addEventListener("keyup", function (keyUpEvent) {
|
||||
if (keyUpEvent.target.nodeName === "INPUT") {
|
||||
return;
|
||||
}
|
||||
});
|
||||
let {code, key, altKey, ctrlKey, shiftKey} = keyUpEvent;
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: 'keyUpEvent',
|
||||
keyUpEvent: {
|
||||
code,
|
||||
key,
|
||||
altKey,
|
||||
ctrlKey,
|
||||
shiftKey
|
||||
}
|
||||
}));
|
||||
}, false);
|
||||
|
||||
window.onblur = function() {
|
||||
// Fake a change event
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
const KEY_P = 80; //Key code for letter p used for Parenting hotkey.
|
||||
|
||||
function loaded() {
|
||||
openEventBridge(function() {
|
||||
elPosY = document.getElementById("horiz-y");
|
||||
|
@ -105,7 +103,7 @@ function loaded() {
|
|||
elColorBlue.value = blue;
|
||||
gridColor = { red: red, green: green, blue: blue };
|
||||
emitUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
elColorRed.addEventListener('change', colorChangeFunction);
|
||||
elColorGreen.addEventListener('change', colorChangeFunction);
|
||||
|
@ -131,15 +129,24 @@ function loaded() {
|
|||
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'init' }));
|
||||
});
|
||||
document.addEventListener("keydown", function (keyDown) {
|
||||
if (keyDown.keyCode === KEY_P && keyDown.ctrlKey) {
|
||||
if (keyDown.shiftKey) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
document.addEventListener("keyup", function (keyUpEvent) {
|
||||
if (keyUpEvent.target.nodeName === "INPUT") {
|
||||
return;
|
||||
}
|
||||
let {code, key, altKey, ctrlKey, shiftKey} = keyUpEvent;
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: 'keyUpEvent',
|
||||
keyUpEvent: {
|
||||
code,
|
||||
key,
|
||||
altKey,
|
||||
ctrlKey,
|
||||
shiftKey
|
||||
}
|
||||
}));
|
||||
}, false);
|
||||
|
||||
// Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked
|
||||
document.addEventListener("contextmenu", function (event) {
|
||||
event.preventDefault();
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
//
|
||||
|
||||
/* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages,
|
||||
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible */
|
||||
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible,
|
||||
keyUpEventFromUIWindow */
|
||||
|
||||
var PROFILING_ENABLED = false;
|
||||
var profileIndent = '';
|
||||
|
@ -298,6 +299,8 @@ EntityListTool = function(shouldUseEditTabletApp) {
|
|||
SelectionManager._update();
|
||||
} else if (data.type === "toggleSpaceMode") {
|
||||
SelectionDisplay.toggleSpaceMode();
|
||||
} else if (data.type === 'keyUpEvent') {
|
||||
keyUpEventFromUIWindow(data.keyUpEvent);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global keyUpEventFromUIWindow */
|
||||
|
||||
var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
|
||||
|
||||
Grid = function() {
|
||||
|
@ -270,24 +272,26 @@ GridTool = function(opts) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (data.type == "init") {
|
||||
if (data.type === "init") {
|
||||
horizontalGrid.emitUpdate();
|
||||
} else if (data.type == "update") {
|
||||
} else if (data.type === "update") {
|
||||
horizontalGrid.update(data);
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
listeners[i] && listeners[i](data);
|
||||
}
|
||||
} else if (data.type == "action") {
|
||||
} else if (data.type === "action") {
|
||||
var action = data.action;
|
||||
if (action == "moveToAvatar") {
|
||||
if (action === "moveToAvatar") {
|
||||
var position = MyAvatar.getJointPosition("LeftFoot");
|
||||
if (position.x == 0 && position.y == 0 && position.z == 0) {
|
||||
if (position.x === 0 && position.y === 0 && position.z === 0) {
|
||||
position = MyAvatar.position;
|
||||
}
|
||||
horizontalGrid.setPosition(position);
|
||||
} else if (action == "moveToSelection") {
|
||||
} else if (action === "moveToSelection") {
|
||||
horizontalGrid.moveToSelection();
|
||||
}
|
||||
} else if (data.type === 'keyUpEvent') {
|
||||
keyUpEventFromUIWindow(data.keyUpEvent);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue