From: Mark Proulx on
Walter Roberson <roberson(a)hushmail.com> wrote in message <i00dbk$g38$1(a)canopus.cc.umanitoba.ca>...
> Mark Proulx wrote:
> > Walter Roberson <roberson(a)hushmail.com> wrote in message
> > <i00btk$dst$1(a)canopus.cc.umanitoba.ca>...
> >> Mark Proulx wrote:
> >> > Consider a situation where a GUI includes a pushbutton that executes
> >> > some code associated with a callback function that is nested in the
> >> GUI > function. Does there exist a mechanism that would allow one to
> >> execute > the callback code via an external command so that the
> >> callback executes > as though the button had actually been pushed?
> >>
> >> Yes, just call the routine with appropriate parameters.
> >>
> >> mybuttoncallback(button_handle, [], arg1, arg2, ...)
> >
> > As always, thanks for the response. This is the approach I'm trying,
> > but for some reason, it isn't working. ML responds with an "undefined
> > function or method..." error, as though the callback function is out of
> > scope. I will continue to work this...
>
> Is it possible that it is a nested routine and you are trying to call it from
> outside of the nest?
>
> If so then you will have to somehow locate the button handle, probably using
> findobj() with an appropriate set of criteria.
>
> h = findobj('Type','uicontrol','Style,'pushbutton','Tag', 'Here_I_am');
>
> then
>
> cb = get(h,'Callback');
> cb{1}(h, [], cb{2:end});

Yes - the callback that I'm trying to call is nested, and yes, I'm trying to call it from outside the nest. I was certain that this was the root of my trouble, but could not conjure a way around it. I even went as far (in debug mode) to invoke the get(h,'Callback'), but did not know what to do with it. Do I correctly interpret this line:

cb{1}(h, [], cb{2:end});

....as the mechanism by which one can invoke the callback having retrieved it with "get?"
From: Mark Proulx on
"Mark Proulx" <mark.p.proulx(a)boeing.com> wrote in message <i00drd$qr3$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <i00dbk$g38$1(a)canopus.cc.umanitoba.ca>...
> > Mark Proulx wrote:
> > > Walter Roberson <roberson(a)hushmail.com> wrote in message
> > > <i00btk$dst$1(a)canopus.cc.umanitoba.ca>...
> > >> Mark Proulx wrote:
> > >> > Consider a situation where a GUI includes a pushbutton that executes
> > >> > some code associated with a callback function that is nested in the
> > >> GUI > function. Does there exist a mechanism that would allow one to
> > >> execute > the callback code via an external command so that the
> > >> callback executes > as though the button had actually been pushed?
> > >>
> > >> Yes, just call the routine with appropriate parameters.
> > >>
> > >> mybuttoncallback(button_handle, [], arg1, arg2, ...)
> > >
> > > As always, thanks for the response. This is the approach I'm trying,
> > > but for some reason, it isn't working. ML responds with an "undefined
> > > function or method..." error, as though the callback function is out of
> > > scope. I will continue to work this...
> >
> > Is it possible that it is a nested routine and you are trying to call it from
> > outside of the nest?
> >
> > If so then you will have to somehow locate the button handle, probably using
> > findobj() with an appropriate set of criteria.
> >
> > h = findobj('Type','uicontrol','Style,'pushbutton','Tag', 'Here_I_am');
> >
> > then
> >
> > cb = get(h,'Callback');
> > cb{1}(h, [], cb{2:end});
>
> Yes - the callback that I'm trying to call is nested, and yes, I'm trying to call it from outside the nest. I was certain that this was the root of my trouble, but could not conjure a way around it. I even went as far (in debug mode) to invoke the get(h,'Callback'), but did not know what to do with it. Do I correctly interpret this line:
>
> cb{1}(h, [], cb{2:end});
>
> ...as the mechanism by which one can invoke the callback having retrieved it with "get?"

This...

cb{1}(h, [], cb{2:end});

....didn't work, but this:

cb(h, [], cb{2:end});

....seems to. It looks like you may have given me what I needed to know. I think.
From: Walter Roberson on
Mark Proulx wrote:

>> Yes - the callback that I'm trying to call is nested, and yes, I'm
>> trying to call it from outside the nest. I was certain that this was
>> the root of my trouble, but could not conjure a way around it. I even
>> went as far (in debug mode) to invoke the get(h,'Callback'), but did
>> not know what to do with it. Do I correctly interpret this line:
>>
>> cb{1}(h, [], cb{2:end});
>>
>> ...as the mechanism by which one can invoke the callback having
>> retrieved it with "get?"
>
> This...
>
> cb{1}(h, [], cb{2:end});
>
> ...didn't work, but this:
>
> cb(h, [], cb{2:end});
>
> ...seems to. It looks like you may have given me what I needed to
> know. I think.

If your callback is defined with {} as in

set(h, 'Callback', {@PushMe, 'Yeh!'})

then you need the cb{1} form. If though you did not use {}, as in

set(h, 'Callback', @PushMe)

then

cb(h, []);

would be appropriate.

If you defined your callback as a string then normally you could feval(), but
in this particular case where the routine is nested that would not work
outside the nest.

From: Mark Proulx on
Walter Roberson <roberson(a)hushmail.com> wrote in message <i00fud$k9l$1(a)canopus.cc.umanitoba.ca>...
> Mark Proulx wrote:
>
> >> Yes - the callback that I'm trying to call is nested, and yes, I'm
> >> trying to call it from outside the nest. I was certain that this was
> >> the root of my trouble, but could not conjure a way around it. I even
> >> went as far (in debug mode) to invoke the get(h,'Callback'), but did
> >> not know what to do with it. Do I correctly interpret this line:
> >>
> >> cb{1}(h, [], cb{2:end});
> >>
> >> ...as the mechanism by which one can invoke the callback having
> >> retrieved it with "get?"
> >
> > This...
> >
> > cb{1}(h, [], cb{2:end});
> >
> > ...didn't work, but this:
> >
> > cb(h, [], cb{2:end});
> >
> > ...seems to. It looks like you may have given me what I needed to
> > know. I think.
>
> If your callback is defined with {} as in
>
> set(h, 'Callback', {@PushMe, 'Yeh!'})
>
> then you need the cb{1} form. If though you did not use {}, as in
>
> set(h, 'Callback', @PushMe)
>
> then
>
> cb(h, []);
>
> would be appropriate.
>
> If you defined your callback as a string then normally you could feval(), but
> in this particular case where the routine is nested that would not work
> outside the nest.

The callback function is 'reset_bttn_Callback' It's defined in the context of a uicontrol, viz.,

hreset = uicontrol(fmstr,'Style','pushbutton',...
'String','Reset',...
'Units','normalized',...
'Position',[0.300,0.100,0.400,0.050],...
'Callback',{@reset_bttn_Callback});

Given this manner of definition, the "cb(h,[])" format works, although I can't say I know this by virtue of anything but tria and error ;-)
From: Jan Simon on
Dear Mark!

> Consider a situation where a GUI includes a pushbutton that executes some code associated with a callback function that is nested in the GUI function. Does there exist a mechanism that would allow one to execute the callback code via an external command so that the callback executes as though the button had actually been pushed?

Straight: Do not use a nested function as call back.
Tricky: Create a Java robot which performs the mouse click. See:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/243113

Good luck, Jan
First  |  Prev  | 
Pages: 1 2
Prev: expm
Next: array manipulation