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

displayOutput hover/click coordinates #33

Open
markgrujic opened this issue Oct 9, 2018 · 2 comments
Open

displayOutput hover/click coordinates #33

markgrujic opened this issue Oct 9, 2018 · 2 comments

Comments

@markgrujic
Copy link

Hi,
Just wondering if there is the capability in the shiny binding to get the location of the cursor as with plotOutput:

plotOutput("plot1", click = "plot_click", dblclick = "plot_dblclick", hover = "plot_hover", brush = "plot_brush" ),

Which are then available via input$plot_click etc. I can't see anything in the docs, so maybe this is a feature request?

@markgrujic
Copy link
Author

Adding to this, being able to extract the coordinates of the extent of the current viewed area (after zooming) would be very useful.

@jkh1
Copy link

jkh1 commented Feb 8, 2019

For on hover events, one needs to modify the function updatePixelPosition() in EBImage/htmlwidgets/lib/viewer/viewer.js by adding the line
Shiny.setInputValue("pixelPosition", pixelPos);
at the end of the function. This will make the mouse pixel coordinates available in the variable input$pixelPosition. Similarly, one can get the current frame by adding
Shiny.setInputValue("currentFrame", currentFrame);
to setFrame() and the image dimensions with:

Shiny.setInputValue("imgWidth", originalWidth);
Shiny.setInputValue("imgHeight", originalHeight);

in reset().
The mouse click function is already used for panning so to get the mouse position in pixel coordinates, one needs to add
Shiny.setInputValue("pixelPosition", viewer.getPixelPosition(event));
to the function grabImage().

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

No branches or pull requests

3 participants