From: Matt J on
When I do this;

>> z=get(datacursormode(gcf))

z =

Enable: 'on'
SnapToDataVertex: 'on'
DisplayStyle: 'datatip'
UpdateFcn: @myupdatefcn
Figure: [1x1 figure]


it shows, according to my understanding, that datatip creation is enabled in the current figure and that myupdatefcn() is to be called when a datatip is created.

Currently, myupdatefcn() is written to print a simple message

>> z.UpdateFcn([])
I'm here

regardless of the input.

However, when I click in this same figure, myupdatefcn() is not launched. The above "I'm here" message does not appear and an ordinary datatip appears in the figure.

Anyone know what I'm misinterpreting?
From: Matt J on
Anyone?
From: Steven Lord on

"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message
news:hsg7d0$ol$1(a)fred.mathworks.com...
> When I do this;
>
>>> z=get(datacursormode(gcf))
>
> z =
> Enable: 'on'
> SnapToDataVertex: 'on'
> DisplayStyle: 'datatip'
> UpdateFcn: @myupdatefcn
> Figure: [1x1 figure]
>
>
> it shows, according to my understanding, that datatip creation is
> enabled in the current figure and that myupdatefcn() is to be called when
> a datatip is created.
> Currently, myupdatefcn() is written to print a simple message
>
>>> z.UpdateFcn([])
> I'm here
>
> regardless of the input.
>
> However, when I click in this same figure, myupdatefcn() is not launched.
> The above "I'm here" message does not appear and an ordinary datatip
> appears in the figure.
>
> Anyone know what I'm misinterpreting?

Does myupdatefcn have the signature that DATACURSORMODE expects it to have,
including the number of inputs it accepts?

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datacursormode.html

What output do you receive when you call myupdatefcn like:

myupdatefcn([], struct('Target', gcf, 'Position', [0.5 0.5]))

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Matt J on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hshpkv$6bl$1(a)fred.mathworks.com>...

> Does myupdatefcn have the signature that DATACURSORMODE expects it to have,
> including the number of inputs it accepts?
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datacursormode.html
>
> What output do you receive when you call myupdatefcn like:
>
> myupdatefcn([], struct('Target', gcf, 'Position', [0.5 0.5]))
=============

I get the following error, which was to be expected, considering that you had me pass a struct instead of an actual event_object

??? Error using ==> get
Conversion to double from struct is not possible.

Error in ==> linkdtips>myupdatefcn at 138
pos = get(event_obj,'Position');

In any case, my diagnosis of the problem has progressed a bit. It seems that the UpdateFcn of the figure's datacursormode object is ignored when there are already other data cursor's in the figure. Does that make any sense?

Apparently, each data cursor object in the figure (if there are any) also have their own UpdateFcn property, which takes precedence over the UpdateFcn property of the figure's datacursormode object. By setting the data cursor's copy of UpdateFcn to @myupdatefcn as well, it does seem to fix my problem (one of them at least).