mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-03 11:32:10 +02:00
Fix click and drag logic for floatingUIExample.js.
This commit is contained in:
parent
d24006e715
commit
1b4ba75b5a
1 changed files with 22 additions and 21 deletions
|
@ -127,35 +127,37 @@ blueSquare3.offsetPosition = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function onMouseDown(event) {
|
var mouseDown = {};
|
||||||
isLeftClick = event.isLeftButton;
|
|
||||||
isRightClick = event.isRightButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseMove(event) {
|
function onMouseDown(event) {
|
||||||
isLeftClick = isRightClick = false;
|
if (event.isLeftButton) {
|
||||||
|
mouseDown.overlay = OverlayManager.findAtPoint({ x: event.x, y: event.y });
|
||||||
|
}
|
||||||
|
if (event.isRightButton) {
|
||||||
|
mouseDown.pos = { x: event.x, y: event.y };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseUp(event) {
|
function onMouseUp(event) {
|
||||||
if (isLeftClick && event.isLeftButton) {
|
if (event.isLeftButton) {
|
||||||
var overlay = OverlayManager.findAtPoint({ x: event.x, y: event.y });
|
var overlay = OverlayManager.findAtPoint({ x: event.x, y: event.y });
|
||||||
print(overlay.attachedPanel);
|
if (overlay === mouseDown.overlay) {
|
||||||
if (overlay.attachedPanel === bluePanel) {
|
if (overlay.attachedPanel === bluePanel) {
|
||||||
overlay.destroy();
|
overlay.destroy();
|
||||||
} else if (overlay) {
|
} else if (overlay) {
|
||||||
var oldPos = overlay.offsetPosition;
|
var oldPos = overlay.offsetPosition;
|
||||||
var newPos = {
|
var newPos = {
|
||||||
x: Number(oldPos.x),
|
x: Number(oldPos.x),
|
||||||
y: Number(oldPos.y),
|
y: Number(oldPos.y),
|
||||||
z: Number(oldPos.z) + 0.1
|
z: Number(oldPos.z) + 0.1
|
||||||
};
|
};
|
||||||
overlay.offsetPosition = newPos;
|
overlay.offsetPosition = newPos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isRightClick && event.isRightButton) {
|
if (event.isRightButton && Vec3.distance(mouseDown.pos, { x: event.x, y: event.y }) < 5) {
|
||||||
mainPanel.visible = !mainPanel.visible;
|
mainPanel.visible = !mainPanel.visible;
|
||||||
}
|
}
|
||||||
isLeftClick = isRightClick = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onScriptEnd() {
|
function onScriptEnd() {
|
||||||
|
@ -163,6 +165,5 @@ function onScriptEnd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(onMouseDown);
|
Controller.mousePressEvent.connect(onMouseDown);
|
||||||
Controller.mouseMoveEvent.connect(onMouseMove);
|
|
||||||
Controller.mouseReleaseEvent.connect(onMouseUp);
|
Controller.mouseReleaseEvent.connect(onMouseUp);
|
||||||
Script.scriptEnding.connect(onScriptEnd);
|
Script.scriptEnding.connect(onScriptEnd);
|
Loading…
Reference in a new issue