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

Selectable overlay #2001

Closed
dnoneill opened this issue Jun 30, 2021 · 2 comments
Closed

Selectable overlay #2001

dnoneill opened this issue Jun 30, 2021 · 2 comments
Assignees
Labels

Comments

@dnoneill
Copy link

Hi have added an overlay the viewer. I can't seem to make it selectable (drag over the text and copy and paste it).
The overlay looks like this:
var elem2 =

Text
this.viewer.addOverlay({ element: elem2, location: rect });

The only way I have been able to make the text selectable is by doing below:
viewer.addHandler('canvas-press', (e) => {
e.preventDefault(); //This causes an error that allows the text to be selectable
//e.originalEvent.preventDefault(); //When I do these two lines it does not work
//e.originalEvent.stopPropagation();
});

Any thoughts. I haven't been able to find anything.

@dnoneill
Copy link
Author

Figured this out.

Needed to add canvasHandler listener to the element.

new openseadragon.MouseTracker({
element: elem2,
canvasHandler: function() {
}
}).setTracking(true);

@msalsbery
Copy link
Member

@dnoneill

For what it's worth, there is no "canvasHandler" in MouseTracker...just attaching a MouseTracker to the element was enough.

That, however, is undocumented behavior, and with v3.0.0 and its major MouseTracker overhaul coming, that may no longer work. You can build and test a 3.0.0 build from the master branch here (or use a preview build from here ) to see if it'll still work in 3.0.0.

If it doesn't still work in 3.0.0, it's a simple change to make it work and you'll still attach a MouseTracker to the overlay element. This CodePen shows an example using 3.0.0 MouseTracker on overlay elements to control this and other common scenarios.

@msalsbery msalsbery reopened this Jun 30, 2021
@msalsbery msalsbery self-assigned this Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants