diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index d135e58d6..56083e009 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -142,7 +142,7 @@ function newFloatingObject () { thisObject.targetImageSize = thisObject.rawImageSize * 2.0 thisObject.targetFontSize = thisObject.rawFontSize * 2.0 - thisObject.underlayingObject.onMouseOver() + thisObject.underlayingObject.container.eventHandler.raiseEvent('onMouseOver') } function onMouseNotOver () { @@ -150,11 +150,15 @@ function newFloatingObject () { thisObject.targetImageSize = thisObject.rawImageSize * 1 thisObject.targetFontSize = thisObject.rawFontSize * 1 - thisObject.underlayingObject.onMouseNotOver() + thisObject.underlayingObject.container.eventHandler.raiseEvent('onMouseNotOver') } function onMouseClick (pPoint) { - thisObject.underlayingObject.onMouseClick(pPoint, thisObject) + let event = { + point: pPoint, + parent: thisObject + } + thisObject.underlayingObject.container.eventHandler.raiseEvent('onMouseClick', event) } function drawBackground () { diff --git a/FloatingSpace/Note.js b/FloatingSpace/Note.js index 24fd8fbb5..6ffd0c76d 100644 --- a/FloatingSpace/Note.js +++ b/FloatingSpace/Note.js @@ -5,9 +5,6 @@ function newNote () { let thisObject = { container: undefined, physicsLoop: physicsLoop, - onMouseOver: onMouseOver, - onMouseClick: onMouseClick, - onMouseNotOver: onMouseNotOver, drawBackground: drawBackground, drawForeground: drawForeground, getContainer: getContainer, @@ -26,7 +23,9 @@ function newNote () { return thisObject function initialize () { - + thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } function getContainer (point) { @@ -51,8 +50,9 @@ function newNote () { } - function onMouseClick (pPoint, pFloatingObject) { - + function onMouseClick (event) { + pPoint = event.point + pFloatingObject = event.parent } function drawBackground (pFloatingObject) { diff --git a/FloatingSpace/ProfileBall.js b/FloatingSpace/ProfileBall.js index eaead239d..e25b39cc9 100644 --- a/FloatingSpace/ProfileBall.js +++ b/FloatingSpace/ProfileBall.js @@ -5,9 +5,6 @@ function newProfileBall () { let thisObject = { container: undefined, physicsLoop: physicsLoop, - onMouseOver: onMouseOver, - onMouseClick: onMouseClick, - onMouseNotOver: onMouseNotOver, drawBackground: drawBackground, drawForeground: drawForeground, getContainer: getContainer, @@ -80,6 +77,10 @@ function newProfileBall () { menuItem.iconOn.src = window.canvasApp.urlPrefix + menuItem.imagePathOn menuItem.icon = menuItem.iconOn // The default value is ON. } + + thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } function getContainer (point) { @@ -124,9 +125,12 @@ function newProfileBall () { } } - function onMouseClick (pPoint, pFloatingObject) { + function onMouseClick (event) { /* What we need to do here is to check which menu item was clicked, if any. */ + pPoint = event.point + pFloatingObject = event.parent + let menuItemIndex for (let i = 0; i < ballStringMenu.length; i++) { diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 0df9d3cf4..d990a205f 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -6,9 +6,6 @@ function newStrategyPart () { type: undefined, container: undefined, physicsLoop: physicsLoop, - onMouseOver: onMouseOver, - onMouseClick: onMouseClick, - onMouseNotOver: onMouseNotOver, drawBackground: drawBackground, drawForeground: drawForeground, getContainer: getContainer, @@ -272,6 +269,10 @@ function newStrategyPart () { menuItem.iconOn.src = window.canvasApp.urlPrefix + menuItem.imagePathOn menuItem.icon = menuItem.iconOn // The default value is ON. } + + thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } function getContainer (point) { @@ -320,9 +321,12 @@ function newStrategyPart () { isMouseOver = false } - function onMouseClick (pPoint, pFloatingObject) { + function onMouseClick (event) { /* What we need to do here is to check which menu item was clicked, if any. */ + pPoint = event.point + pFloatingObject = event.parent + let menuItemIndex for (let i = 0; i < ballStringMenu.length; i++) {