mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 23:13:48 +02:00
use local messaging to disable mouse-grab when edit.js is active
This commit is contained in:
parent
9db528d7a3
commit
0b6f52f508
2 changed files with 26 additions and 1 deletions
|
@ -345,6 +345,7 @@ var toolBar = (function() {
|
|||
if (active && !Entities.canAdjustLocks()) {
|
||||
Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG);
|
||||
} else {
|
||||
Messages.sendMessage("edit-events", JSON.stringify({enabled: active}));
|
||||
isActive = active;
|
||||
if (!isActive) {
|
||||
entityListTool.setVisible(false);
|
||||
|
@ -1949,4 +1950,4 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) {
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,6 +49,8 @@ var IDENTITY_QUAT = {
|
|||
};
|
||||
var ACTION_TTL = 10; // seconds
|
||||
|
||||
var enabled = true;
|
||||
|
||||
function getTag() {
|
||||
return "grab-" + MyAvatar.sessionUUID;
|
||||
}
|
||||
|
@ -306,6 +308,10 @@ Grabber.prototype.computeNewGrabPlane = function() {
|
|||
}
|
||||
|
||||
Grabber.prototype.pressEvent = function(event) {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isLeftButton!==true ||event.isRightButton===true || event.isMiddleButton===true) {
|
||||
return;
|
||||
}
|
||||
|
@ -559,8 +565,26 @@ function keyReleaseEvent(event) {
|
|||
grabber.keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
function editEvent(channel, message, sender) {
|
||||
if (channel != "edit-events") {
|
||||
return;
|
||||
}
|
||||
if (sender != MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
data = JSON.parse(message);
|
||||
if ("enabled" in data) {
|
||||
enabled = !data["enabled"];
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
Controller.mousePressEvent.connect(pressEvent);
|
||||
Controller.mouseMoveEvent.connect(moveEvent);
|
||||
Controller.mouseReleaseEvent.connect(releaseEvent);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Messages.subscribe("edit-events");
|
||||
Messages.messageReceived.connect(editEvent);
|
||||
|
|
Loading…
Reference in a new issue