Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Would there be any example for consuming a custom cornerstone tool please? #103

Open
getnsv opened this issue Sep 3, 2020 · 3 comments

Comments

@getnsv
Copy link

getnsv commented Sep 3, 2020

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

@lennart-g
Copy link

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 #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

@lennart-g
Copy link

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

@lennart-g
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants