Path: news.mathworks.com!not-for-mail
From: "David Doria" <daviddoria@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Axes tools in GUI
Date: Fri, 18 Jul 2008 13:33:03 +0000 (UTC)
Organization: Rensselaer Polytechnic Institute
Lines: 36
Message-ID: <g5q62f$jst$1@fred.mathworks.com>
References: <g414n2$no7$1@fred.mathworks.com> <e432d979-f637-4ab4-aca0-cffe9372ee6e@g16g2000pri.googlegroups.com> <g4dmdi$a0u$1@fred.mathworks.com> <g4dmtv$h8f$1@fred.mathworks.com> <g4dp9g$l9p$1@fred.mathworks.com> <g4e775$pgn$1@fred.mathworks.com> <g4e97d$ldf$1@fred.mathworks.com> <g4g4qa$3k3$1@fred.mathworks.com>
Reply-To: "David Doria" <daviddoria@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216387983 20381 172.30.248.35 (18 Jul 2008 13:33:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 18 Jul 2008 13:33:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1408202
Xref: news.mathworks.com comp.soft-sys.matlab:480259



Someone emailed me asking for clarification, so I thought
I'd post it here:

First I set this:
p = imshow(whatever);
set(p, 'ButtonDownFcn', @(h, eventdata) GetClick(handles) );

I then have this as a nested function in the GUI m file:

function GetClick(handles)                                 
                                                           
                                              
                                                           
                                                           
                                              
CurrentPoint = get(handles.axes1, 'CurrentPoint');         
                                                           
                                              
ClickedScan = round(CurrentPoint(1,1));                    
                                                           
                                              
ClickedCol = round(CurrentPoint(1,2));                     
                                                           
                                              
                                                           
                                                           
                                              
disp(['Selected Scan: ' num2str(ClickedScan) ' Col: '
num2str(ClickedCol)]);     


Seems to do the trick!

Good luck,

Dave