mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 11:53:28 +02:00
Added Hotkey Listening to the webview
Ctrl + P and Ctrl + Shift + P are now available even if the edit window has been selected
This commit is contained in:
parent
f5d266a562
commit
dcbe3c622d
7 changed files with 52 additions and 47 deletions
|
@ -1374,12 +1374,6 @@ var keyReleaseEvent = function (event) {
|
|||
});
|
||||
grid.setPosition(newPosition);
|
||||
}
|
||||
} else if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) {
|
||||
if (event.isShifted) {
|
||||
unparentSelectedEntities();
|
||||
} else {
|
||||
parentSelectedEntities();
|
||||
}
|
||||
}
|
||||
};
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
|
@ -1586,6 +1580,7 @@ var PropertiesTool = function (opts) {
|
|||
print('Edit.js received web event that was not valid json.')
|
||||
return;
|
||||
}
|
||||
print(JSON.stringify(data))
|
||||
var i, properties, dY, diff, newPosition;
|
||||
if (data.type === "print") {
|
||||
if (data.message) {
|
||||
|
@ -1924,7 +1919,11 @@ var particleExplorerTool = new ParticleExplorerTool();
|
|||
var selectedParticleEntity = 0;
|
||||
entityListTool.webView.webEventReceived.connect(function (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.type === "selectionUpdate") {
|
||||
if(data.type === 'parent') {
|
||||
parentSelectedEntities();
|
||||
} else if(data.type === 'unparent') {
|
||||
unparentSelectedEntities();
|
||||
} else if (data.type === "selectionUpdate") {
|
||||
var ids = data.entityIds;
|
||||
if (ids.length === 1) {
|
||||
if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
<script type="text/javascript" src="js/spinButtons.js"></script>
|
||||
<script type="text/javascript" src="js/keyboardControl.js"></script>
|
||||
<script type="text/javascript" src="js/entityList.js"></script>
|
||||
<script type="text/javascript" src="js/parentingHotkey.js"></script>
|
||||
</head>
|
||||
<body onload='loaded();'>
|
||||
<div id="entity-list-header">
|
||||
|
@ -91,7 +90,6 @@
|
|||
</tfoot>
|
||||
</table>
|
||||
|
||||
<input type="button" class="green" id="parent" value="Parent" />
|
||||
<div id="no-entities">
|
||||
No entities found <span id="no-entities-in-view">in view</span> within a <span id="no-entities-radius">100</span> meter radius. Try moving to a different location and refreshing.
|
||||
</div>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<script type="text/javascript" src="js/keyboardControl.js"></script>
|
||||
<script type="text/javascript" src="js/entityProperties.js"></script>
|
||||
<script src="js/jsoneditor.min.js"></script>
|
||||
<script type="text/javascript" src="js/parentingHotkey.js"></script>
|
||||
</head>
|
||||
<body onload='loaded();'>
|
||||
<div id="properties-list">
|
||||
|
|
|
@ -26,7 +26,7 @@ debugPrint = function (message) {
|
|||
};
|
||||
|
||||
function loaded() {
|
||||
openEventBridge(function() {
|
||||
openEventBridge(function() {
|
||||
entityList = new List('entity-list', { valueNames: ['name', 'type', 'url', 'locked', 'visible'], page: MAX_ITEMS});
|
||||
entityList.clear();
|
||||
elEntityTable = document.getElementById("entity-table");
|
||||
|
@ -48,7 +48,7 @@ function loaded() {
|
|||
elNoEntitiesInView = document.getElementById("no-entities-in-view");
|
||||
elNoEntitiesRadius = document.getElementById("no-entities-radius");
|
||||
elEntityTableScroll = document.getElementById("entity-table-scroll");
|
||||
|
||||
|
||||
document.getElementById("entity-name").onclick = function() {
|
||||
setSortColumn('name');
|
||||
};
|
||||
|
@ -90,7 +90,7 @@ function loaded() {
|
|||
selection = selection.concat(selectedEntities);
|
||||
} else if (clickEvent.shiftKey && selectedEntities.length > 0) {
|
||||
var previousItemFound = -1;
|
||||
var clickedItemFound = -1;
|
||||
var clickedItemFound = -1;
|
||||
for (var entity in entityList.visibleItems) {
|
||||
if (clickedItemFound === -1 && this.dataset.entityId == entityList.visibleItems[entity].values().id) {
|
||||
clickedItemFound = entity;
|
||||
|
@ -113,11 +113,11 @@ function loaded() {
|
|||
selection = selection.concat(betweenItems, selectedEntities);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
selectedEntities = selection;
|
||||
|
||||
|
||||
this.className = 'selected';
|
||||
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "selectionUpdate",
|
||||
focus: false,
|
||||
|
@ -126,7 +126,7 @@ function loaded() {
|
|||
|
||||
refreshFooter();
|
||||
}
|
||||
|
||||
|
||||
function onRowDoubleClicked() {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "selectionUpdate",
|
||||
|
@ -134,7 +134,7 @@ function loaded() {
|
|||
entityIds: [this.dataset.entityId],
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
const BYTES_PER_MEGABYTE = 1024 * 1024;
|
||||
|
||||
function decimalMegabytes(number) {
|
||||
|
@ -173,7 +173,7 @@ function loaded() {
|
|||
currentElement.onclick = onRowClicked;
|
||||
currentElement.ondblclick = onRowDoubleClicked;
|
||||
});
|
||||
|
||||
|
||||
if (refreshEntityListTimer) {
|
||||
clearTimeout(refreshEntityListTimer);
|
||||
}
|
||||
|
@ -183,13 +183,13 @@ function loaded() {
|
|||
item.values({ name: name, url: filename, locked: locked, visible: visible });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clearEntities() {
|
||||
entities = {};
|
||||
entityList.clear();
|
||||
refreshFooter();
|
||||
}
|
||||
|
||||
|
||||
var elSortOrder = {
|
||||
name: document.querySelector('#entity-name .sort-order'),
|
||||
type: document.querySelector('#entity-type .sort-order'),
|
||||
|
@ -215,12 +215,12 @@ function loaded() {
|
|||
entityList.sort(currentSortColumn, { order: currentSortOrder });
|
||||
}
|
||||
setSortColumn('type');
|
||||
|
||||
|
||||
function refreshEntities() {
|
||||
clearEntities();
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'refresh' }));
|
||||
}
|
||||
|
||||
|
||||
function refreshFooter() {
|
||||
if (selectedEntities.length > 1) {
|
||||
elFooter.firstChild.nodeValue = selectedEntities.length + " entities selected";
|
||||
|
@ -239,7 +239,7 @@ function loaded() {
|
|||
entityList.search(elFilter.value);
|
||||
refreshFooter();
|
||||
}
|
||||
|
||||
|
||||
function updateSelectedEntities(selectedIDs) {
|
||||
var notFound = false;
|
||||
for (var id in entities) {
|
||||
|
@ -262,7 +262,7 @@ function loaded() {
|
|||
|
||||
return notFound;
|
||||
}
|
||||
|
||||
|
||||
elRefresh.onclick = function() {
|
||||
refreshEntities();
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ function loaded() {
|
|||
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
||||
refreshEntities();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("keydown", function (keyDownEvent) {
|
||||
if (keyDownEvent.target.nodeName === "INPUT") {
|
||||
return;
|
||||
|
@ -292,8 +292,15 @@ function loaded() {
|
|||
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
||||
refreshEntities();
|
||||
}
|
||||
if (keyDownEvent.keyCode === 80 && keyDownEvent.ctrlKey) {
|
||||
if (keyDownEvent.shiftKey) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
||||
var isFilterInView = false;
|
||||
var FILTER_IN_VIEW_ATTRIBUTE = "pressed";
|
||||
elNoEntitiesInView.style.display = "none";
|
||||
|
@ -320,7 +327,7 @@ function loaded() {
|
|||
if (window.EventBridge !== undefined) {
|
||||
EventBridge.scriptEventReceived.connect(function(data) {
|
||||
data = JSON.parse(data);
|
||||
|
||||
|
||||
if (data.type === "clearEntityList") {
|
||||
clearEntities();
|
||||
} else if (data.type == "selectionUpdate") {
|
||||
|
@ -426,4 +433,3 @@ function loaded() {
|
|||
event.preventDefault();
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElemen
|
|||
propertyValue += subPropertyString + ',';
|
||||
}
|
||||
} else {
|
||||
// We've unchecked, so remove
|
||||
// We've unchecked, so remove
|
||||
propertyValue = propertyValue.replace(subPropertyString + ",", "");
|
||||
}
|
||||
|
||||
|
@ -780,7 +780,7 @@ function loaded() {
|
|||
if (lastEntityID !== '"' + properties.id + '"' && lastEntityID !== null && editor !== null) {
|
||||
saveJSONUserData(true);
|
||||
}
|
||||
//the event bridge and json parsing handle our avatar id string differently.
|
||||
//the event bridge and json parsing handle our avatar id string differently.
|
||||
|
||||
lastEntityID = '"' + properties.id + '"';
|
||||
elID.innerHTML = properties.id;
|
||||
|
@ -1390,7 +1390,7 @@ function loaded() {
|
|||
elZoneFlyingAllowed.addEventListener('change', createEmitCheckedPropertyUpdateFunction('flyingAllowed'));
|
||||
elZoneGhostingAllowed.addEventListener('change', createEmitCheckedPropertyUpdateFunction('ghostingAllowed'));
|
||||
elZoneFilterURL.addEventListener('change', createEmitTextPropertyUpdateFunction('filterURL'));
|
||||
|
||||
|
||||
var voxelVolumeSizeChangeFunction = createEmitVec3PropertyUpdateFunction(
|
||||
'voxelVolumeSize', elVoxelVolumeSizeX, elVoxelVolumeSizeY, elVoxelVolumeSizeZ);
|
||||
elVoxelVolumeSizeX.addEventListener('change', voxelVolumeSizeChangeFunction);
|
||||
|
@ -1441,7 +1441,15 @@ function loaded() {
|
|||
}));
|
||||
});
|
||||
|
||||
|
||||
document.addEventListener("keydown", function (keyDown) {
|
||||
if (keyDown.keyCode === 80 && keyDown.ctrlKey) {
|
||||
if (keyDown.shiftKey) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
}
|
||||
}
|
||||
});
|
||||
window.onblur = function() {
|
||||
// Fake a change event
|
||||
var ev = document.createEvent("HTMLEvents");
|
||||
|
|
|
@ -131,10 +131,17 @@ function loaded() {
|
|||
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'init' }));
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (keyDown) {
|
||||
if (keyDown.keyCode === 80 && keyDown.ctrlKey) {
|
||||
if (keyDown.shiftKey) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
}
|
||||
}
|
||||
})
|
||||
// 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();
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
var keyReleaseEvent = function (event) {
|
||||
if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) {
|
||||
if (event.isShifted) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.onkeypress = keyReleaseEvent;
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
Loading…
Reference in a new issue