Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot object hit area?

Subject: plot object hit area?

From: Sven

Date: 28 May, 2010 21:37:21

Message: 1 of 4

Hi all,

Is there a property of a plot object that determines its clickable area?

For example, consider the two lines:
figure, p1 = plot([0 1],[0 1],'-b.','linewidth',2,'ButtonDownFcn','disp HIT')
and
figure, p2 = plot([0 1],[0 1],'-b.','linewidth',20,'ButtonDownFcn','disp HIT')

It is much easier to 'hit' p2 with a mouse click than it is p1, because the line is thicker. Is there a way to have thin lines, but have the clickability of a thicker line? Perhaps some plot property somewhere such as "hitAreaMargin" that I'm looking for?

Cheers,
Sven.

Subject: plot object hit area?

From: us

Date: 28 May, 2010 21:48:21

Message: 2 of 4

"Sven" <sven.holcombe@gmail.deleteme.com> wrote in message <htpd2h$idm$1@fred.mathworks.com>...
> Hi all,
>
> Is there a property of a plot object that determines its clickable area?
>
> For example, consider the two lines:
> figure, p1 = plot([0 1],[0 1],'-b.','linewidth',2,'ButtonDownFcn','disp HIT')
> and
> figure, p2 = plot([0 1],[0 1],'-b.','linewidth',20,'ButtonDownFcn','disp HIT')
>
> It is much easier to 'hit' p2 with a mouse click than it is p1, because the line is thicker. Is there a way to have thin lines, but have the clickability of a thicker line? Perhaps some plot property somewhere such as "hitAreaMargin" that I'm looking for?
>
> Cheers,
> Sven.

no
us

Subject: plot object hit area?

From: Matt Fig

Date: 28 May, 2010 22:01:23

Message: 3 of 4

I can think of instances where it would be useful to let a user have an easier time with clicking on a line. If it is really worth it to you for your particular application, consider plotting an identical yet thicker line under the visible one, and setting its color to white. Then set its buttondownfcn to match the visible line. For example:

figure
plot([0 1],[0 1],'-w.','linewidth',...
      10,'ButtonDownFcn','disp HIT',...
      'handlevisibility','off')
hold on
plot([0 1],[0 1],'-b.','ButtonDownFcn','disp HIT')

Subject: plot object hit area?

From: Sven

Date: 28 May, 2010 22:25:10

Message: 4 of 4

> no
> us

Ha! Pithy.

Cheers all, and yeah, Matt, I was thinking along those lines too.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us