From 9dfd5f3e8d7cc26dff6030c55cc3dd0ced931959 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 6 May 2019 09:20:23 +0200 Subject: [PATCH] Focus removed correctly --- FloatingSpace/FloatingObject.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 12d00d38f..13b2eced3 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -103,7 +103,10 @@ function newFloatingObject () { thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + /* To consider that this object lost the focus, we monitor the space for 2 key events */ + canvas.floatingSpace.container.eventHandler.listenToEvent('onMouseOver', mouseOverFlotingSpace) + canvas.floatingSpace.container.eventHandler.listenToEvent('onFocusAquired', someoneAquiredFocus) if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } } catch (err) { @@ -171,14 +174,25 @@ function newFloatingObject () { thisObject.underlayingObject.container.eventHandler.raiseEvent('onMouseOver', point) thisObject.positionLocked = true + canvas.floatingSpace.container.eventHandler.raiseEvent('onFocusAquired', thisObject.container) } - function onMouseNotOver (point) { + function mouseOverFlotingSpace (point) { + removeFocus() + } + + function someoneAquiredFocus (container) { + if (container.id !== thisObject.container.id) { + removeFocus() + } + } + + function removeFocus () { thisObject.targetRadius = thisObject.rawRadius * 1 thisObject.targetImageSize = thisObject.rawImageSize * 1 thisObject.targetFontSize = thisObject.rawFontSize * 1 - thisObject.underlayingObject.container.eventHandler.raiseEvent('onMouseNotOver', point) + thisObject.underlayingObject.container.eventHandler.raiseEvent('onMouseNotOver') thisObject.positionLocked = false }