diff --git a/Canvas.js b/Canvas.js index f4c56f015..8ef7e6bf9 100644 --- a/Canvas.js +++ b/Canvas.js @@ -546,7 +546,7 @@ function newCanvas () { /* If it is not, then we check if it is over any of the existing containers at the Chart Space. */ - container = thisObject.chartSpace.getContainer(point) + container = thisObject.chartSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) if (container !== undefined && container.detectMouseOver === true) { container.eventHandler.raiseEvent('onMouseOver', point) @@ -601,7 +601,7 @@ function newCanvas () { /* Finally we try the Chart Space. */ - let chartContainer = canvas.chartSpace.getContainer({ x: point.x, y: point.y }) + let chartContainer = canvas.chartSpace.getContainer({ x: point.x, y: point.y }, GET_CONTAINER_PURPOSE.MOUSE_WHEEL) if (chartContainer !== undefined && chartContainer.isWheelable === true) { chartContainer.eventHandler.raiseEvent('Mouse Wheel', event) diff --git a/Container.js b/Container.js index 19d327dc8..442957f08 100644 --- a/Container.js +++ b/Container.js @@ -10,7 +10,8 @@ function newContainer () { isWheelable: false, name: undefined, initialize: initialize, - connectToParent: connectToParent + connectToParent: connectToParent, + isForThisPurpose: isForThisPurpose } let connectedToParentWidth = false @@ -72,4 +73,29 @@ function newContainer () { function onMouseOver (event) { thisObject.eventHandler.raiseEvent('onMouseOver', event) } + + function isForThisPurpose (purpose) { + if (purpose !== undefined) { + switch (purpose) { + case GET_CONTAINER_PURPOSE.MOUSE_OVER: + if (thisObject.detectMouseOver === true) { + return true + } + break + case GET_CONTAINER_PURPOSE.MOUSE_WHEEL: + if (thisObject.isWheelable === true) { + return true + } + break + case GET_CONTAINER_PURPOSE.MOUSE_CLICK: + if (thisObject.isClickeable === true) { + return true + } + break + default: { return false } + + } + } + return false + } } diff --git a/Globals.js b/Globals.js index cc24a3bcb..61cd669b2 100644 --- a/Globals.js +++ b/Globals.js @@ -38,6 +38,12 @@ UI_FONT = { FONT_ASPECT_RATIO = 0.45; const MIN_ZOOM_LEVEL = -28.25 +const GET_CONTAINER_PURPOSE = { + MOUSE_OVER: 1, + MOUSE_WHEEL: 2, + MOUSE_CLICK: 3 +} + /* User Interface Panels */ UI_PANEL = { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index fc8cc4010..2486cb0a7 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -104,7 +104,7 @@ function newChartSpace () { } } - function getContainer (point) { + function getContainer (point, purpose) { if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') } let container @@ -112,17 +112,13 @@ function newChartSpace () { /* Now we see which is the inner most container that has it */ for (var i = 0; i < this.timeMachines.length; i++) { - container = this.timeMachines[i].getContainer(point) - + container = this.timeMachines[i].getContainer(point, purpose) if (container !== undefined) { - /* We found an inner container which has the point. We return it. */ - - return container + if (container.isForThisPurpose(purpose)) { + return container + } } } - - /* The point does not belong to any inner container, so we return the current container. */ - return this.container } } diff --git a/TimeMachine.js b/TimeMachine.js index cefd6e951..bfd9c20eb 100644 --- a/TimeMachine.js +++ b/TimeMachine.js @@ -189,23 +189,24 @@ function newTimeMachine () { timeScale.draw() } - function getContainer (point) { - if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') } - + function getContainer (point, purpose) { let container - /* Now we see which is the inner most container that has it */ - container = timeScale.getContainer(point) - if (container !== undefined) { return container } + if (container !== undefined) { + if (container.isForThisPurpose(purpose)) { + return container + } + } for (let i = 0; i < this.charts.length; i++) { container = this.charts[i].getContainer(point) - if (container !== undefined) { return container } + if (container !== undefined) { + if (container.isForThisPurpose(purpose)) { + return container + } + } } - - /* The point does not belong to any inner container, so we return the current container. */ - return this.container } } diff --git a/Utilities.js b/Utilities.js index 454d7edc9..2ea30bde1 100644 --- a/Utilities.js +++ b/Utilities.js @@ -150,3 +150,4 @@ function removeTime (datetime) { return dateOnly } +