IHittable: add snapping and respect data area clipping
See original GitHub issueFeature Suggestion
Feature description:
Hello Scott, I just played a bit with the IHittable
interface, and here are some comments about it and potential ideas to improve it I hope
- The current implementation of
IHittable
does not account for margins, asIDraggable
does. There is no snap distance, making it difficult to implement and useIHittable
on points (instead of polygons) - At the moment, it seems
IHittable
can only be activated/disactivated, allowing to hit an object on an event (e.g) mouse click could be a nice addition if not already possible. This would improve performance forIHittable
ScatterPlot
s - I think the detection performed on draggables with the
isUnderMouse
is redundant with what should be implemented inHitTest
, especially considering the addition of the snap distances. There is a probable refactor to be done here sinceIDraggable
seems to be aIHittable
(or more likelyIHoverable
but that just semantics) with extra steps.
The most difficult thing, with respect to the current implementation seems to be the ability to catch mouse events. Do you think this could be done without too much hassle ? Also that would be really nice to have that in v5 don’t you think ?
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Plottable: IHittable · Issue #1844 · ScottPlot ...
I just added this internally to my program for vLines using the ... IHittable: add snapping and respect data area clipping #1962.
Read more >Position elements with snapping in Photoshop
Use snapping. Snapping helps with precise placement of selection edges, cropping marquees, slices, shapes, and paths. However, if snapping ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How to select the nearest point on click (not on mouse move)
Hi @BambOoxX, I think I found a solution! Let me know if this helps you get your job done, and if not I’m happy to work together to come up with one. We can continue the conversation here or on the Discord! (#1966)
Does this code/screenshot adequately demonstrate the idea? This can be achieved using the existing published library.
Let’s not modify IHittable
One of my big design goals for ScottPlot 5 is to make it easier to customize behavior using client-side code (rather than requiring a developer to anticipate and build-in all the various combinations of functionality users may want).
I still have some work to do figuring out the best API here, but I’m considering not supporting
IHittable
or evenIDraggable
, but instead trying to make it as easy as possible for the user to implement their own hit detection and/or dragging code on their side. We’ll see how it goes 🤞I’m happy this issue resulted in a new WinForms demo showing how IHittable works (#1985), but I don’t think I’ll go all the way and add the complexity of unit/pixel state management necessary for IHittable to support pixel snapping.
Regarding v5. I know very little about such complex designs, but would it be possible for each plottable to have a MouseEvent and KeyboardEvent property so that one could link actions to plottables?
Also, I think some sort of ReturnOnEvent could have practical use. Because in general when I want interaction in a plottable it’s because I need to retrieve some information about it related to the action I performed with either mouse or key.
Not sure if this helps but these are my two cents