Question: Would there be any example for consuming a custom cornerstone tool please?
Hi @dannyrb ,
Am trying to create a custom tool using cornerstone base tool. Got the code from https://tools.cornerstonejs.org/custom-tools/#creating-your-tool.
But am stuck on how to consume this, as just using the below is giving me an exception. the variable is undefined...
const MyTool = cornerstoneTools.MyTool; //is coming undefined and hence exception cornerstoneTools.addTool(MyTool); cornerstoneTools.setToolActive('myTool', { mouseButtonMask: 1 });
Any guidance will be very helpful.
thanks, Sreevani
Hi, also trying to create a custom tool.
Code Sandbox: https://codesandbox.io/s/thirsty-payne-fpc5f?file=/src/initCornerstone.js
Using example tool from https://tools.cornerstonejs.org/custom-tools/#event-dispatcher-callbacks and followed steps from https://github.com/cornerstonejs/react-cornerstone-viewport/issues/63
Expected behavior: console log upon mouse click, initial console log upon tool activation.
Actual behavior: Unable to find tool "HelloWorldMouse" for enabledElement + none of the expected actions
By the way, the long term goal is to write my own annotation tools (more simplistic than the currently provided ones), I hope I'm on the right track with the above.
Thanks
Moved the tool adding part to the Viewports onElementEnabled event and now everything works. Code in the sandbox is updated. I guess this also answers the question for the thread author.