From: Adam on
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
"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
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.