Path: news.mathworks.com!not-for-mail
From: "Nima Nikvand" <nnikvand@uwaterloo.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Event Object for Datacursormode
Date: Sun, 30 Dec 2012 20:51:07 +0000 (UTC)
Organization: University of Waterloo
Lines: 30
Message-ID: <kbq9fr$39j$1@newscl01ah.mathworks.com>
References: <kboj05$ahe$1@newscl01ah.mathworks.com> <kbon7f$njj$1@newscl01ah.mathworks.com> <kbosk1$b1q$1@newscl01ah.mathworks.com>
Reply-To: "Nima Nikvand" <nnikvand@uwaterloo.ca>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1356900667 3379 172.30.248.47 (30 Dec 2012 20:51:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 30 Dec 2012 20:51:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2050963
Xref: news.mathworks.com comp.soft-sys.matlab:785624

Hi Matt,

I am getting an empty matrix as the output of my ancestor function, a simple code like this for example:

fig = figure(1);
x=0:0.01:10,
y = sin(x);
plot(x,y);

dcmObj=datacursormode(fig);
p=ancestor(dcmObj,'figure')

is also returning p=[]. 

"Matt J" wrote in message <kbosk1$b1q$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <kbon7f$njj$1@newscl01ah.mathworks.com>...
> > "Nima Nikvand" <nnikvand@uwaterloo.ca> wrote in message <kboj05$ahe$1@newscl01ah.mathworks.com>...
> > >
> > > function [txt,pos] = datatextbox(~,event_obj)
> > > 
> > > and this works very well. However, I'd like to be able to get the output of my datatextbox function and I was wondering if I can some how call the function directly by passing the event_obj to it. I'd greatly appreciate your suggestions, or any other solutions to get the output arguments.
> > =============
> > 
> > If you make datatextbox a nested function, every variable in its workspace will also be available in the workspace in which it is nested.
> 
> You could also call setappdata from within datatextbox and store the txt,pos output data to the parent figure. Pass the figure handle to datatextbox using this syntax
> 
>  set(dcmObj,'UpdateFcn',{@datatextbox, ancestor(dcmObj,'figure')});
> 
> Then use getappdata to pull it out later.