cornerstoneTools icon indicating copy to clipboard operation
cornerstoneTools copied to clipboard

Dynamic change mouse cursor

Open qqsea opened this issue 4 years ago • 3 comments

Prerequisites

  • [ ] Which version are you using? (Is it latest?)
  • [ ] Are you reporting to the correct repository?
  • [ ] Did you search existing issues? (Were any related?)

Description

I set tool active for three tools at the same time like pan, zoom, wwwc, for each tool the mouseButtonMask is 1, 2, 4. Now when left button of mouse down which mask is 1, the cursor is for pan, this is right. But when I mouse down the right button or wheel button (mask is 2 or 4), the cursor still for pan. The expect is the cursor for zoom or wwwc.

I made some investigation on how to change the cursor, but no result. Because the setToolCursor is not exported by the lib of csTools. So what should I do to meet the requirement?

qqsea avatar May 27 '20 09:05 qqsea

The cursor defaults to the active left click tool. We could expose the method you need in src/lib.js?

We could also update the library to set a different cursor for the other active tools when they're engaged. Although, I would want to verify that's how other viewers/editors approach this problem.

dannyrb avatar May 29 '20 03:05 dannyrb

Yes ,if the tool cursor setting api exported by src/lib.js, it will meet my requirement. Now I figured out a walk round that monitoring the mouse down and up event to setToolActive. Here is the code snips:

 mouseDown(e) {
      var mouseButton = this.getEventButtons(e.detail.event);
      if ([2, 4].indexOf(mouseButton) === -1) return;
      if (mouseButton == 2) {
        cornerstoneTools.setToolDisabled(this.currentInteractionMode);
        cornerstoneTools.setToolActive("Wwwc", { mouseButtonMask: [1, 2] });
      }

      if (mouseButton == 4) {
        cornerstoneTools.setToolDisabled(this.currentInteractionMode);
        cornerstoneTools.setToolActive("Zoom", { mouseButtonMask: [1, 4] });
      }
    }

qqsea avatar Jun 04 '20 05:06 qqsea

@dannyrb have you considered exposing the method setToolCursor? I am currently struggling with the same issue described here, but would like to avoid the walk around mentioned.

janaoravcova avatar Feb 06 '24 10:02 janaoravcova