Skip to content

Commit d8a6157

Browse files
committed
Added sending currently moused-over ref-line info with right and left single clicks.
1 parent cda8d83 commit d8a6157

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

d3_resources/SpectrumChartD3.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ SpectrumChartD3.prototype.getMouseUpOrSingleFingerUpHandler = function( coords,
25252525

25262526
// Emit the tap signal, unhighlight any peaks that are highlighted
25272527
console.log( "Emit TAP/click signal! - coords:", coords );
2528-
self.WtEmit(self.chart.id, {name: 'leftclicked'}, coords[4], coords[5], coords[2], coords[3]);
2528+
self.WtEmit(self.chart.id, {name: 'leftclicked'}, coords[4], coords[5], coords[2], coords[3], self.currentRefLineInfoStr() );
25292529

25302530
if( self.options.allowDragRoiExtent && self.mouseDownRoi && !modKeyDown ){
25312531
self.showRoiDragOption(self.mouseDownRoi, [coords[0],coords[1]], true);
@@ -2538,6 +2538,12 @@ SpectrumChartD3.prototype.getMouseUpOrSingleFingerUpHandler = function( coords,
25382538
};
25392539
};//handleSingleFingerUp
25402540

2541+
SpectrumChartD3.prototype.currentRefLineInfoStr = function () {
2542+
let ref_line = "";
2543+
if( this.mousedOverRefLine && this.mousedOverRefLine.__data__ && this.mousedOverRefLine.__data__.parent )
2544+
ref_line = this.mousedOverRefLine.__data__.parent.parent;
2545+
return ref_line;
2546+
}
25412547

25422548

25432549
SpectrumChartD3.prototype.handleVisMouseUp = function () {
@@ -2579,7 +2585,7 @@ SpectrumChartD3.prototype.handleVisMouseUp = function () {
25792585
console.log("Should alter context menu for the highlighted peak" );
25802586
}
25812587

2582-
self.WtEmit(self.chart.id, {name: 'rightclicked'}, energy, count, pageX, pageY);
2588+
self.WtEmit(self.chart.id, {name: 'rightclicked'}, energy, count, pageX, pageY, self.currentRefLineInfoStr());
25832589
self.handleCancelAllMouseEvents()();
25842590

25852591
return;
@@ -2605,13 +2611,7 @@ SpectrumChartD3.prototype.handleVisMouseUp = function () {
26052611
self.mouseDownRoi = null;
26062612
}
26072613

2608-
let ref_line = "";
2609-
if( self.mousedOverRefLine && self.mousedOverRefLine.__data__ && self.mousedOverRefLine.__data__.parent )
2610-
{
2611-
ref_line = self.mousedOverRefLine.__data__.parent.parent;
2612-
console.log( "self.mousedOverRefLine:", self.mousedOverRefLine, ", data:", self.mousedOverRefLine.__data__, ", parent:", self.mousedOverRefLine.__data__.parent );
2613-
}
2614-
self.WtEmit(self.chart.id, {name: 'doubleclicked'}, energy, count, ref_line);
2614+
self.WtEmit(self.chart.id, {name: 'doubleclicked'}, energy, count, self.currentRefLineInfoStr() );
26152615
} else {
26162616
// This is the first click - maybe there will be another click, maybe not
26172617
if( !modKeyPressed )
@@ -3008,7 +3008,7 @@ SpectrumChartD3.prototype.handleVisTouchStart = function() {
30083008
// Emit the tap signal, unhighlight any peaks that are highlighted
30093009
if ( dx <= 15 || dy <= 15 ) {
30103010
console.log( "Emit TAP HOLD (RIGHT TAP) signal!", "\nenergy = ", energy, ", count = ", count, ", x = ", origTouch.pageX, ", y = ", origTouch.pageY );
3011-
self.WtEmit(self.chart.id, {name: 'rightclicked'}, energy, count, origTouch.pageX, origTouch.pageY);
3011+
self.WtEmit(self.chart.id, {name: 'rightclicked'}, energy, count, origTouch.pageX, origTouch.pageY, self.currentRefLineInfoStr() );
30123012
self.handleCancelAllMouseEvents()();
30133013
self.unhighlightPeak(null);
30143014
self.touchHoldEmitted = true;
@@ -3383,8 +3383,9 @@ SpectrumChartD3.prototype.handleVisTouchEnd = function() {
33833383
&& self.dist([self.lastTapEvent.changedTouches[0].pageX, self.lastTapEvent.changedTouches[0].pageY], [pageX, pageY]) < tapRadius) {
33843384

33853385
// Emit the double-tap signal, clear any touch lines/highlighted peaks in chart
3386-
console.log( "Emit TAP doubleclicked signal! energy=", energy, ', count=', count );
3387-
self.WtEmit(self.chart.id, {name: 'doubleclicked'}, energy, count);
3386+
//console.log( "Emit TAP doubleclicked signal! energy=", energy, ', count=', count );
3387+
3388+
self.WtEmit(self.chart.id, {name: 'doubleclicked'}, energy, count, self.currentRefLineInfoStr());
33883389
deleteTouchLine();
33893390
self.unhighlightPeak(null);
33903391
} else {

0 commit comments

Comments
 (0)