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

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com