Xifeng
Xifeng

Reputation: 1

How do I change the keystroke problem for OpenSeadragon?

I'm trying to change the keys of OpenSeadragon, the default is left button and long press to drag the picture, I want to change it to right button long press and drag, what should I do, below is the code I tried, but it doesn't seem to work effect

<script>
        var mouse = OpenSeadragon.Button({
            element:'view',
        });
        mouse.isTracking(true)
        mouse.dragHandler(function (event){
            event.buttons = 0
        });
    });
</script>

Upvotes: 0

Views: 156

Answers (1)

iangilman
iangilman

Reputation: 2174

There's no simple "switch drag to the right mouse button" feature in OSD, but it's possible you could implement it. You'll have to disable the viewer.innerTracker.dragHandler by setting it to null, and then create new functions for these three handlers:

  • viewer.innerTracker.nonPrimaryPressHandler
  • viewer.innerTracker.moveHandler
  • viewer.innerTracker.nonPrimaryReleaseHandler

You'll need to implement your own drag functionality, since OSD doesn't have a "non-primary drag" handler. As for the actual panning functionality, you can take a look at how it currently does it with the left mouse drag.

https://github.com/openseadragon/openseadragon/blob/d3ef7674874ce5b5fd5d52816acbe4708e24c44a/src/viewer.js#L2949

Upvotes: 0

Related Questions