fixed mouse mappings

This commit is contained in:
Connor Turland 2014-11-22 16:47:09 -05:00
parent 2de697bcca
commit c1728b9ecb
2 changed files with 27 additions and 36 deletions

View file

@ -2495,7 +2495,7 @@ Extras.Classes.Navigation = new Class({
//START METAMAPS CODE //START METAMAPS CODE
var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey); var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey);
// TODO make sure this works across browsers // TODO make sure this works across browsers
if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) { if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || rightClick)) {
Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos(); Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos();
//console.log('mouse down'); //console.log('mouse down');
} }
@ -2525,13 +2525,13 @@ Extras.Classes.Navigation = new Class({
// START METAMAPS CODE // START METAMAPS CODE
var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey); var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey);
if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) { if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || rightClick)) {
Metamaps.Visualize.mGraph.busy = true; Metamaps.Visualize.mGraph.busy = true;
Metamaps.boxStartCoordinates = eventInfo.getPos(); Metamaps.boxStartCoordinates = eventInfo.getPos();
//console.log('mouse move'); //console.log('mouse move');
return; return;
} }
if (Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) { if (Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || rightClick)) {
Metamaps.Visualize.mGraph.busy = true; Metamaps.Visualize.mGraph.busy = true;
Metamaps.JIT.drawSelectBox(eventInfo,e); Metamaps.JIT.drawSelectBox(eventInfo,e);
//console.log('mouse move'); //console.log('mouse move');

View file

@ -374,14 +374,14 @@ Metamaps.JIT = {
$('.rightclickmenu').remove(); $('.rightclickmenu').remove();
if (Metamaps.Mouse.boxStartCoordinates) { if (Metamaps.Mouse.boxStartCoordinates) {
if(e.ctrlKey && e.shiftKey){ if(e.ctrlKey){
Metamaps.Visualize.mGraph.busy = false; Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.zoomToBox(e); Metamaps.JIT.zoomToBox(e);
//console.log('called zoom to box'); //console.log('called zoom to box');
return; return;
} }
else if (e.ctrlKey || e.shiftKey) { else if (e.shiftKey) {
Metamaps.Visualize.mGraph.busy = false; Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.selectWithBox(e); Metamaps.JIT.selectWithBox(e);
@ -410,10 +410,10 @@ Metamaps.JIT = {
// remove the rightclickmenu // remove the rightclickmenu
$('.rightclickmenu').remove(); $('.rightclickmenu').remove();
if (Metamaps.Mouse.boxStartCoordinates && e.ctrlKey) { if (Metamaps.Mouse.boxStartCoordinates) {
Metamaps.Visualize.mGraph.busy = false; Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.zoomToBox(e); Metamaps.JIT.selectWithBox(e);
return; return;
} }
@ -1097,7 +1097,7 @@ Metamaps.JIT = {
eX = Metamaps.Mouse.boxEndCoordinates.x, eX = Metamaps.Mouse.boxEndCoordinates.x,
eY = Metamaps.Mouse.boxEndCoordinates.y; eY = Metamaps.Mouse.boxEndCoordinates.y;
if(!(e.shiftKey) && !(e.ctrlKey)){ if(!e.shiftKey){
Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges(); Metamaps.Control.deselectAllEdges();
} }
@ -1108,7 +1108,7 @@ Metamaps.JIT = {
y = n.pos.y; y = n.pos.y;
if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) { if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) {
if(e.ctrlKey){ if(e.shiftKey){
if(n.selected){ if(n.selected){
Metamaps.Control.deselectNode(n); Metamaps.Control.deselectNode(n);
} }
@ -1211,7 +1211,7 @@ Metamaps.JIT = {
var node2id = synapse.get('edge').nodeTo.id; var node2id = synapse.get('edge').nodeTo.id;
var edge = Metamaps.Visualize.mGraph.graph.getAdjacence(node1id, node2id); var edge = Metamaps.Visualize.mGraph.graph.getAdjacence(node1id, node2id);
if(selectTest){ if(selectTest){
if(e.ctrlKey){ if(e.shiftKey){
if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){
Metamaps.Control.deselectEdge(synapse.get('edge')); Metamaps.Control.deselectEdge(synapse.get('edge'));
} }
@ -1273,23 +1273,19 @@ Metamaps.JIT = {
// wait a certain length of time, then check again, then run this code // wait a certain length of time, then check again, then run this code
setTimeout(function () { setTimeout(function () {
if (!Metamaps.JIT.nodeWasDoubleClicked()) { if (!Metamaps.JIT.nodeWasDoubleClicked()) {
if (!e.shiftKey && !e.ctrlKey) {
var nodeAlreadySelected = node.selected;
if (!e.shiftKey) {
Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges(); Metamaps.Control.deselectAllEdges();
Metamaps.Control.selectNode(node,e);
} }
else if(e.shiftKey && e.ctrlKey){
//no result if (nodeAlreadySelected) {
}
else if(e.ctrlKey){
if (node.selected) {
Metamaps.Control.deselectNode(node); Metamaps.Control.deselectNode(node);
} else { } else {
Metamaps.Control.selectNode(node,e); Metamaps.Control.selectNode(node,e);
} }
}else if(e.shiftKey){
Metamaps.Control.selectNode(node,e);
}
//trigger animation to final styles //trigger animation to final styles
Metamaps.Visualize.mGraph.fx.animate({ Metamaps.Visualize.mGraph.fx.animate({
@ -1531,24 +1527,19 @@ Metamaps.JIT = {
// wait a certain length of time, then check again, then run this code // wait a certain length of time, then check again, then run this code
setTimeout(function () { setTimeout(function () {
if (!Metamaps.JIT.nodeWasDoubleClicked()) { if (!Metamaps.JIT.nodeWasDoubleClicked()) {
if (!e.shiftKey && !e.ctrlKey) {
var edgeAlreadySelected = Metamaps.Selected.Edges.indexOf(adj) !== -1;
if (!e.shiftKey) {
Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges(); Metamaps.Control.deselectAllEdges();
Metamaps.Control.selectEdge(adj);
} }
else if (e.shiftKey && e.ctrlKey){
//no result if (edgeAlreadySelected) {
}
else if (e.ctrlKey){
if (Metamaps.Selected.Edges.indexOf(adj) !== -1) {
Metamaps.Control.deselectEdge(adj); Metamaps.Control.deselectEdge(adj);
} else { } else {
Metamaps.Control.selectEdge(adj); Metamaps.Control.selectEdge(adj);
} }
}
else if (e.shiftKey){
Metamaps.Control.selectEdge(adj);
}
Metamaps.Visualize.mGraph.plot(); Metamaps.Visualize.mGraph.plot();
} }