From: Corey Kelly on 26 May 2010 17:06 Walter Roberson <roberson(a)hushmail.com> wrote in message <htju1a$fr9$2(a)canopus.cc.umanitoba.ca>... > Corey Kelly wrote: > > > I've re-written my callback following those guidelines: > > > > set(handles.currimage, > > 'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata,handles)); > > > > > > and while I'm not getting any errors, I think there's still an issue > > with handles being passed properly to the callback. > > Yes, that would pass down the value of handles as of the time that the > callback was defined. As handles is a structure, that is not what you want. > > As you will not be changing the figure number (I gather), pass down the figure > number and in the callback > > handles = guidata(FigureNumber) I understand what you mean, but I'm not sure I understand your solution. What is the figure number? I can't find anything about it in the documentation. Also, if I pass down the figure number, then define handles in the callback, does that mean that I don't have to pass handles to the function? i.e.: set(handles.currimage,'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata));
From: Corey Kelly on 26 May 2010 17:07 Walter Roberson <roberson(a)hushmail.com> wrote in message <htju1a$fr9$2(a)canopus.cc.umanitoba.ca>... > Corey Kelly wrote: > > > I've re-written my callback following those guidelines: > > > > set(handles.currimage, > > 'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata,handles)); > > > > > > and while I'm not getting any errors, I think there's still an issue > > with handles being passed properly to the callback. > > Yes, that would pass down the value of handles as of the time that the > callback was defined. As handles is a structure, that is not what you want. > > As you will not be changing the figure number (I gather), pass down the figure > number and in the callback > > handles = guidata(FigureNumber) I understand what you mean, but I'm not sure I understand your solution. What is the figure number? I can't find anything about it in the documentation. Also, if I pass down the figure number, then define handles in the callback, does that mean that I don't have to pass handles to the function? i.e.: set(handles.currimage,'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata));
From: us on 26 May 2010 17:15 "Corey Kelly" <ckelly01(a)uoguelph.ca> wrote in message <htk2hp$jc3$1(a)fred.mathworks.com>... > Walter Roberson <roberson(a)hushmail.com> wrote in message <htju1a$fr9$2(a)canopus.cc.umanitoba.ca>... > > Corey Kelly wrote: > > > > > I've re-written my callback following those guidelines: > > > > > > set(handles.currimage, > > > 'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata,handles)); > > > > > > > > > and while I'm not getting any errors, I think there's still an issue > > > with handles being passed properly to the callback. > > > > Yes, that would pass down the value of handles as of the time that the > > callback was defined. As handles is a structure, that is not what you want. > > > > As you will not be changing the figure number (I gather), pass down the figure > > number and in the callback > > > > handles = guidata(FigureNumber) > > I understand what you mean, but I'm not sure I understand your solution. What is the figure number? I can't find anything about it in the documentation. > Also, if I pass down the figure number, then define handles in the callback, does that mean that I don't have to pass handles to the function? i.e.: > set(handles.currimage,'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata)); a hint: - make sure that you pass the final handle(s) to your callback function(!)... us
From: Corey Kelly on 27 May 2010 07:20 "Steven Lord" <slord(a)mathworks.com> wrote in message <htk0c4$qgt$1(a)fred.mathworks.com>... > > "Walter Roberson" <roberson(a)hushmail.com> wrote in message > news:htju1a$fr9$2(a)canopus.cc.umanitoba.ca... > > Corey Kelly wrote: > > > >> I've re-written my callback following those guidelines: > >> > >> set(handles.currimage, > >> 'ButtonDownFcn',@(src,eventdata)axes1_ButtonDownFcn(src,eventdata,handles)); > >> and while I'm not getting any errors, I think there's still an issue with > >> handles being passed properly to the callback. > > > > Yes, that would pass down the value of handles as of the time that the > > callback was defined. As handles is a structure, that is not what you > > want. > > > > As you will not be changing the figure number (I gather), pass down the > > figure number and in the callback > > > > handles = guidata(FigureNumber) > > Actually, GUIDATA can accept any figure descendant as its input; since no > Handle Graphics object can be parented to more than one figure at the same > time, this unambiguously specifies the figure from which you want to > retrieve the data. Since you're already passing the handle to a figure > descendant (src) into the ButtonDownFcn, there's no need to add an extra one > to the argument list, and this simplifies the SET call (as long as > axes1_ButtonDownFcn accepts the standard two inputs.) > > set(handles.currimage, 'ButtonDownFcn',@axes1_ButtonDownFcn); > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com > Steve, I much prefer your version of the set() call, but I'm not sure what you mean by the "standard two inputs." My gui was started in GUIDE, and all of my functions take (hObject, eventdata, handles) as arguments. I'm assuming eventdata is the unnecessary one? Also, us, could you clarify what you mean by the "final handles"? I thought I was passing all handles to the callback. Walter, I still haven't been able to find anything regarding the figure number, and passing it as an argument to the guidata() function. I've played around with passing the GUI name as an argument, but that just seems to refresh my GUI and centre it on the screen.
From: us on 27 May 2010 07:38
"Corey Kelly" > > set(handles.currimage, 'ButtonDownFcn',@axes1_ButtonDownFcn); > Also, us, could you clarify what you mean by the "final handles"? I thought I was passing all handles to the callback. well... to solve the conundrum, you could try this... % edit your function % search the callback subroutine % put a KEYBOARD statement before the first line of code % run the gui % click... % now inspect all the inputs us |