correctly handle unselect and dont show highlight when other tool is active

This commit is contained in:
ZappoMan 2014-10-10 21:39:05 -07:00
parent f21ff76a38
commit caac5881bf
2 changed files with 35 additions and 30 deletions

View file

@ -2254,8 +2254,9 @@ SelectionDisplay = (function () {
break; break;
default: default:
// nothing to do by default // nothing to do by default
break; return false;
} }
return true;
}; };
that.mouseReleaseEvent = function(event) { that.mouseReleaseEvent = function(event) {
@ -2289,9 +2290,9 @@ SelectionDisplay = (function () {
}; };
// NOTE: mousePressEvent from the main script should call us., so we don't // NOTE: mousePressEvent and mouseMoveEvent from the main script should call us., so we don't hook these:
// hook the Controller.mousePressEvent.connect(that.mousePressEvent); ourselves. // Controller.mousePressEvent.connect(that.mousePressEvent);
Controller.mouseMoveEvent.connect(that.mouseMoveEvent); // Controller.mouseMoveEvent.connect(that.mouseMoveEvent);
Controller.mouseReleaseEvent.connect(that.mouseReleaseEvent); Controller.mouseReleaseEvent.connect(that.mouseReleaseEvent);
return that; return that;

View file

@ -338,13 +338,15 @@ function rayPlaneIntersection(pickRay, point, normal) {
function mousePressEvent(event) { function mousePressEvent(event) {
mouseLastPosition = { x: event.x, y: event.y }; mouseLastPosition = { x: event.x, y: event.y };
entitySelected = false;
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y }); var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) { if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) {
// Event handled; do nothing. // Event handled; do nothing.
return; return;
} else { } else {
entitySelected = false;
selectionDisplay.unselectAll();
// If we aren't active and didn't click on an overlay: quit // If we aren't active and didn't click on an overlay: quit
if (!isActive) { if (!isActive) {
return; return;
@ -441,8 +443,12 @@ function mouseMoveEvent(event) {
return; return;
} }
// allow the selectionDisplay to handle the event first, if it doesn't handle it, then do our own thing
if (selectionDisplay.mouseMoveEvent(event)) {
return;
}
var pickRay = Camera.computePickRay(event.x, event.y); var pickRay = Camera.computePickRay(event.x, event.y);
if (!entitySelected) {
var entityIntersection = Entities.findRayIntersection(pickRay); var entityIntersection = Entities.findRayIntersection(pickRay);
if (entityIntersection.accurate) { if (entityIntersection.accurate) {
if(highlightedEntityID.isKnownID && highlightedEntityID.id != entityIntersection.entityID.id) { if(highlightedEntityID.isKnownID && highlightedEntityID.id != entityIntersection.entityID.id) {
@ -467,8 +473,6 @@ function mouseMoveEvent(event) {
} }
} }
return;
}
} }