Path: news.mathworks.com!not-for-mail
From: "Steven_Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Event Object for Datacursormode
Date: Sun, 30 Dec 2012 23:05:43 -0500
Organization: MathWorks
Lines: 44
Message-ID: <kbr2un$noc$1@newscl01ah.mathworks.com>
References: <kboj05$ahe$1@newscl01ah.mathworks.com> <kbon7f$njj$1@newscl01ah.mathworks.com> <kbosk1$b1q$1@newscl01ah.mathworks.com> <kbq6v7$olu$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: ah-slord.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="UTF-8";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Trace: newscl01ah.mathworks.com 1356926743 24332 172.28.9.169 (31 Dec 2012 04:05:43 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 31 Dec 2012 04:05:43 +0000 (UTC)
In-Reply-To: <kbq6v7$olu$1@newscl01ah.mathworks.com>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: news.mathworks.com comp.soft-sys.matlab:785640



"Nima Nikvand" <nnikvand@uwaterloo.ca> wrote in message 
news:kbq6v7$olu$1@newscl01ah.mathworks.com...
> Hello Matt,
>
> Thanks for your replies to both my posts. I modified my 
> datatextboxfunction as follows to store my desired variables in figure 
> handles:
>
> function [txt,pos] = datatextbox(~,event_obj,ancestor)
>        pos = get(event_obj,'Position');
>        txt = {['Vector Length: ',num2str(pos(1))],...
>               ['MOS: ',num2str(pos(2))]};
>           setappdata(handles.figure1,'img',pos);
>           %setappdata(handles.figure2,'txtx',txt);
>
>    end
>
> However, now my data tip is not showing the correct information (Vector 
> length and Mos) , and shows Error in Custom data tip function instead. 
> When I remove the setappdata function it starts working again.

Set a breakpoint on the first line of the datatextbox function then attempt 
to reproduce the error. Step through the function until it throws the error. 
Determine why the error occurs and fix it.

Alternately, instead of using handles.figure1, use ANCESTOR on the Target 
property of the event_obj object to retrieve its figure ancestor.

http://www.mathworks.com/help/matlab/ref/datacursormode.html

    "Handle of the object the data cursor is referencing (the object which 
you click, for example, a line or a bar from a series)"

You can then set its application data or use GUIDATA to share whatever 
information you want.

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com