Got Questions? Get Answers.
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:
counting mouse clicks

Subject: counting mouse clicks

From: Julien

Date: 27 Oct, 2008 22:55:04

Message: 1 of 2

Hi,

I want to get the number of clicks I made in a plot by using the buttondownfcn callback, but I don't know how to implement the count variable back to the main function:

function mousecount
 
count=0;
axes('buttondownfcn',{@click,count});
 
 
    function click(gcbo,eventdata,count)
 
    count=count+1;
    disp(count);

...?

Thanks for the help,

Julien

Subject: counting mouse clicks

From: Husam Aldahiyat

Date: 3 Nov, 2008 15:02:01

Message: 2 of 2

What I do is put an invisible text in the GUI ('visible','off') and set its string to 0 ('string','0').

Then in the buttondownfcn, get the number from the text, increment it, and put the new value in its place. That way I don't have to worry about globals and whatnot.

Maybe there' a simpler way but this is fast and it works nice.

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