annotorious / annotorious-openseadragon

An OpenSeadragon plugin for annotating high-res zoomable images
https://annotorious.github.io
BSD 3-Clause "New" or "Revised" License
121 stars 43 forks source link

Can't Create An Annotation after Single Click. #168

Open SaiGovardhana opened 1 year ago

SaiGovardhana commented 1 year ago

Description

I am experiencing an issue with the Annotorious OpenSeadragon plugin, where I am not able to create a rectangle anymore if I hold the shift key or select the rectangle and hit a single click.

Steps to reproduce:

1.)Hold the shift key or select the rectangle and hit a single click. 2.)Try to select a rectangle.

You can replicate the bug on the getting started page of annotorious :

https://annotorious.github.io/getting-started/osd-plugin/

SaiGovardhana commented 1 year ago

It seems that when we single click, the releaseHandler is called:

In src/OSDAnnotationLayer.js, Line 200:

      releaseHandler: evt => {
        if (this.tools.current.isDrawing) {
          firstDragDone = true;

          const { x , y } = this.tools.current.getSVGPoint(evt.originalEvent);
          this.tools.current.onMouseUp(x, y, evt.originalEvent);

          if (dragging && this.tools.current.onDragEnd)
            this.tools.current.onDragEnd();
        }

But it doesn't call the complete Event Handler:

In src/OSDAnnotationLayer.js, Line 150:

    this.tools.on('complete', shape => {
      firstDragDone = false;
      this.onDrawingComplete(shape);
    });

Commenting Out The Following Fixes My Issue But i don't know if it's a good idea as it makes the firstDragDone meaningless :

In src/OSDAnnotationLayer.js, Line 200:

      releaseHandler: evt => {
        if (this.tools.current.isDrawing) {
         //Commenting out the below line
          // firstDragDone = true; 
          const { x , y } = this.tools.current.getSVGPoint(evt.originalEvent);
          this.tools.current.onMouseUp(x, y, evt.originalEvent);

          if (dragging && this.tools.current.onDragEnd)
            this.tools.current.onDragEnd();
        }

fndget commented 1 year ago

I really want to know the solution to this

rsimon commented 1 year ago

Hi, I'm not sure I can follow the bug description. Can you explain what you expect to see? Holding shift will switch to drawing mode, therefore:

the annotation is not supposed to become selected. You are in drawing mode, therefore holding shift and clicking (and dragging) will create a new annotation, on top of the existing one. Is this not what you want?

Do you have any specific customization settings on? I.e. have you disabled or change the SHIFT hotkey to something else? Are you using headless mode or have drawOnSingleClick set to true?

SaiGovardhana commented 1 year ago

Thanks For the Response.

What I meant was once you hold down shift and single click, It doesn't create an annotation, That is fine as expected But it prevents me from making further selections by double clicking and dragging.

So after entering drawing mode and making a single click, I cannot make any further drawing.

I think it is not related to my configuration, as it can also replicated here: https://annotorious.github.io/getting-started/osd-plugin/

rsimon commented 1 year ago

Ah - thanks, I see now! Hold SHIFT, click once, release SHIFT - and then drawing no longer works. I can reproduce. Will look into it!

rsimon commented 1 year ago

Ok, this will require deeper investigation - and my not get fixed in this major version of Annotorious any more. (I'm already working on v3, which will be a full rewrite, and which will have a fundamentally different internal architecture.) If you can work with commenting out firstDragDone, then that would be my recommended workaround for now. Mind, however, that this will likely break expected behavior when using polygon selection. (Boxes shouldn't be affected I think.)