Commit a4bd63af authored by olau@iola.dk's avatar olau@iola.dk

Introduced a plotselecting event which is fired while doing a selection

git-svn-id: https://flot.googlecode.com/svn/trunk@114 1e0a6537-2640-0410-bfb7-f154510ff394
parent 6a7f952e
...@@ -1666,9 +1666,16 @@ ...@@ -1666,9 +1666,16 @@
if (options.grid.hoverable && !hoverTimeout) if (options.grid.hoverable && !hoverTimeout)
hoverTimeout = setTimeout(onHover, 100); hoverTimeout = setTimeout(onHover, 100);
if (selection.active) if (selection.active) {
var r = null;
if (selectionIsSane())
r = getSelectionForEvent();
target.trigger("plotselecting", [ r ]);
updateSelection(lastMousePos); updateSelection(lastMousePos);
} }
}
function onMouseDown(e) { function onMouseDown(e) {
if (e.which != 1) // only accept left-click if (e.which != 1) // only accept left-click
...@@ -1862,7 +1869,7 @@ ...@@ -1862,7 +1869,7 @@
0, true, series.xaxis, series.yaxis, octx); 0, true, series.xaxis, series.yaxis, octx);
} }
function triggerSelectedEvent() { function getSelectionForEvent() {
var x1 = Math.min(selection.first.x, selection.second.x), var x1 = Math.min(selection.first.x, selection.second.x),
x2 = Math.max(selection.first.x, selection.second.x), x2 = Math.max(selection.first.x, selection.second.x),
y1 = Math.max(selection.first.y, selection.second.y), y1 = Math.max(selection.first.y, selection.second.y),
...@@ -1877,6 +1884,11 @@ ...@@ -1877,6 +1884,11 @@
r.yaxis = { from: axes.yaxis.c2p(y1), to: axes.yaxis.c2p(y2) }; r.yaxis = { from: axes.yaxis.c2p(y1), to: axes.yaxis.c2p(y2) };
if (axes.y2axis.used) if (axes.y2axis.used)
r.y2axis = { from: axes.y2axis.c2p(y1), to: axes.y2axis.c2p(y2) }; r.y2axis = { from: axes.y2axis.c2p(y1), to: axes.y2axis.c2p(y2) };
return r;
}
function triggerSelectedEvent() {
var r = getSelectionForEvent();
target.trigger("plotselected", [ r ]); target.trigger("plotselected", [ r ]);
...@@ -1900,6 +1912,9 @@ ...@@ -1900,6 +1912,9 @@
triggerSelectedEvent(); triggerSelectedEvent();
clickIsMouseUp = true; clickIsMouseUp = true;
} }
else
// this counts as a clear
target.trigger("plotselecting", [ null ]);
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment