Clickable transparent lines are impossible?

4 views (last 30 days)
So I have 3 lines (technically patches) that have some transparency enabled. These lines were generated by the patchline FEX submission. The FEX entry works great by making patches seem like lines by adding a NaN to the end of the data so it doesn't create a big black patch between the end points of my line.
My lines looks like this
__ __
\ /
_ \ / _
\ \__/ /
The patch extends from the left end point to the right end point in a straight line across the top and then follows the line on the bottom. The actual patch is hidden (not drawn) though so all the user sees is the lines
The problem is if I wanted to click the bottom hump of the top line, it acts like I clicked the bottom line because it is part of that patch.
I have thought of a couple of workarounds and was hoping you guys could point out flaws or add ideas I might have missed with my workarounds.
Workaround #1
Ideally, I would create an actual line (line series obj.) over the transparent lines. I would turn hittest off on the patches and I would make the actual line invisible, but turn hittest on. The problem I am 99% sure exists is that if visibilty is off, you can't click the object. If anybody has a work around to that issue (documented or otherwise), that would be great.
Workaround #2
Turn the patchline hittest property to off. Make mock line objs. that follow the patchline coords. and have a line width very very small so as to make the line ideally pretty much invisible and have hit test clicks point to these lines instead. Has anybody tried something like this before? (I'm at work and can't try it now)
Workaround #3
NOTE THAT I REALLY DONT WANT TO DO THIS It is of course possible to turn off hittest for the patch/line objs and use the axes buttondown to figure out what patch obj (just the line part) it was closest to.
Once again, any insight would be much appreciated either about my possible work arounds, the situation in general, etc.
Thanks, Shaun

Accepted Answer

Jan on 19 Jun 2013
Workaround #1: Invisible objects do not register hits.
Workaround #2: "Very small" lines are still displayed as 1 pixel width, so they are not almost invisible
Workaround #3: That's it. The AXES' buttondown function is the most direct method, if you want to detect clicks on (partially) invisible objects. If you imagine the lines/axes/etc as real objects made of paper, the axes is the physical object you will access. This might help: FEX: NearestPoint.

More Answers (1)

Shaun VanWeelden
Shaun VanWeelden on 19 Jun 2013
Thanks Jan for the answer! I actually got it right before you posted your idea, for me, I knew the plot lines would never intersect, so if I drew the bottom patches first and worked my way to the top, it worked because all the patch lines were still visible. To anybody else who stumbles upon this, rearanging plot/child order could help you also! The key is though that the lines can't intersect.


Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!