Skip to content

Fix Configuration.MiddleClickDragZoom and rendering artifact if Alt is lifted prematurely#742

Merged
swharden merged 4 commits intoScottPlot:masterfrom
bclehmann:fix-zoom-rect
Feb 5, 2021
Merged

Fix Configuration.MiddleClickDragZoom and rendering artifact if Alt is lifted prematurely#742
swharden merged 4 commits intoScottPlot:masterfrom
bclehmann:fix-zoom-rect

Conversation

@bclehmann
Copy link
Member

New Contributors:
please review CONTRIBUTING.md

Purpose:
Referenced in #741 (comment)

Currently when Configuration.MiddleClickDragZoom is disabled the rectangle will still be drawn, and it will not disappear upon release of the mouse. With this fix the rectangle will not be drawn at all.

New Functionality:
N/A

@bclehmann
Copy link
Member Author

In testing this I noticed another issue, when using Alt + Left Click the box will stop expanding if alt is released, and then the control will be panned as if alt was never pressed.

This may be desired behaviour, except that the box will not disappear.

@bclehmann
Copy link
Member Author

I changed it so if the user releases Alt before they release mouse1 they zoom to that box. Unfortunately if the mouse cursor is still at the point they release Alt it will only do this once they move the mouse again (because it's in the MouseMove handler). Makes me wonder if ScottPlot should support KeyUp/KeyDown events? Although I should admit that I don't know how necessary it is, even in this situation it's not that noticeable unless you're looking for it. Still, if there were a KeyUp event the fix would be much simpler.

@swharden swharden mentioned this pull request Feb 5, 2021
@swharden swharden changed the title Fixes issue with disabled MiddleClickDragZoom still drawing the box Fix Configuration.MiddleClickDragZoom and rendering artifact if Alt is lifted prematurely Feb 5, 2021
@swharden
Copy link
Member

swharden commented Feb 5, 2021

Thanks for this PR @bclehmann, and I'm happy you discovered the secondary bug!

In the case of prematurely lifting Alt, I called Settings.ZoomRectangle.Clear(); so the axes aren't changed and it acts like the zoom was never started.

Probably the keypress capture is unnecessary at this time, but something interesting to consider! It would certainly be possible to listen to keypresses, but I suspect this is a pretty niche use case so I'm happy to leave this one like it is 👍

@swharden swharden linked an issue Feb 5, 2021 that may be closed by this pull request
@swharden swharden merged commit 25db9f7 into ScottPlot:master Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alt left click zoom

2 participants