From 2bb76a357a81b25e6fa132402c530579fb88c552 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper <1p-cusack@1stplayable.com> Date: Thu, 17 Aug 2017 17:28:12 -0400 Subject: [PATCH] [Case 6491] Some adjustments to isActiveTool (details below). * isActiveTool now respects null and undefined args. * If null or undefined toolHandle is passed, activeTool is directly tested against those values. Rather than explicitly returning false. * Added some clarification to unknown tool warning message. Reviewed-by: Leander Hasty Changes Committed: modified: scripts/system/libraries/entitySelectionTool.js --- .../system/libraries/entitySelectionTool.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 49fa11813a..9f0d820f69 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1087,23 +1087,23 @@ SelectionDisplay = (function() { return tool; } - // toolHandle: The overlayID associated with the tool - // that correlates to the tool you wish to query. + // @param: toolHandle: The overlayID associated with the tool + // that correlates to the tool you wish to query. + // @note: If toolHandle is null or undefined then activeTool + // will be checked against those values as opposed to + // the tool registered under toolHandle. Null & Undefined + // are treated as separate values. // @return: bool - Indicates if the activeTool is that queried. function isActiveTool(toolHandle) { - var wantDebug = false; - if ( ! activeTool || ! toolHandle ){ - if(wantDebug){ - if ( activeTool ){ - print("WARNING: entitySelectionTool.isActiveTool - Encountered invalid toolHandle: " + toolHandle ); - } - } - return false; + if ( ! toolHandle ) { + // Allow isActiveTool( null ) and similar to return true if there's + // no active tool + return ( activeTool === toolHandle ); } + if ( ! grabberTools.hasOwnProperty( toolHandle ) ) { - if(wantDebug){ - print("WARNING: entitySelectionTool.isActiveTool - Encountered unknown grabberToolHandle: " + toolHandle ); - } + print("WARNING: entitySelectionTool.isActiveTool - Encountered unknown grabberToolHandle: " + toolHandle + ". Tools should be egistered via addGrabberTool." ); + //--EARLY EXIT-- return false; }