Prev: Error: "MATLAB cannot be opened because of a problem"
Next: Slider Listening/Callback not working
From: Adam on 10 Jun 2010 12:49 Hi, This a simple question. I'm trying to access the handle of the figure generated by my guide GUI from within another function. Currently, I'm using guihandles=guidata(gcf) from within my function, but I would like to replace gcf with something more reliable in case the user switches focus to another figure. Is there a way to find the name of the handle in my GUIDE gui? Thanks
From: Adam on 10 Jun 2010 13:09 "Adam " <abc5(a)ubc.ca> wrote in message <hur522$o6n$1(a)fred.mathworks.com>... > Hi, > > This a simple question. I'm trying to access the handle of the figure generated by my guide GUI from within another function. Currently, I'm using guihandles=guidata(gcf) from within my function, but I would like to replace gcf with something more reliable in case the user switches focus to another figure. Is there a way to find the name of the handle in my GUIDE gui? Thanks One thing I failed to mention is that I do not want to pass the handle as a parameter to my function because this function is not directly called by the GUI. It is a subfunction, meaning all the previous functions would also need to pass the handles.
From: Adam on 10 Jun 2010 13:29 I figured it out. If anyone else is wondering: Use set(gcf, 'Name', 'younamehere'). From within the GUI openingfcn. Then to find the handle use: handleName= findobj(0,Name','yournamehere') To get the handles back: newHandles=guidata(handleName) The only thing I'm worried about now, is that findobj and guidata might be expensive to call every-time this function is called. Passing the handles is probably cheaper but will make all functions have one more parameter. Anyways, thanks for the help.
|
Pages: 1 Prev: Error: "MATLAB cannot be opened because of a problem" Next: Slider Listening/Callback not working |