<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169008</link>
    <title>MATLAB Central Newsreader - guidata returns empty array on CreateFcn callback?</title>
    <description>Feed for thread: guidata returns empty array on CreateFcn callback?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 09 May 2008 15:43:03 -0400</pubDate>
      <title>guidata returns empty array on CreateFcn callback?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169008#431265</link>
      <author>Ian Clarkson</author>
      <description>Hello all!&lt;br&gt;
&lt;br&gt;
I have a listbox which I'm trying to populate with some&lt;br&gt;
information I'd like to save. The listbox should populate as&lt;br&gt;
soon as the figure shows, so I've added the code within the&lt;br&gt;
CreateFcn callback. The GUIDE skeleton for the function&lt;br&gt;
(MATLAB R12.1) is:&lt;br&gt;
&lt;br&gt;
function varargout = listbox_CreateFcn(h, eventdata,&lt;br&gt;
handles, varargin)&lt;br&gt;
&lt;br&gt;
The 'handles' variable is empty. When I try to call&lt;br&gt;
guidata(h), it also returns an empty array. guihandles&lt;br&gt;
returns all of the handles in the figure, but when I try to&lt;br&gt;
call guidata to save to any of the handles returned by&lt;br&gt;
guihandles, they don't seem to save so they're accessible by&lt;br&gt;
other callbacks later on. I'm very confused about what&lt;br&gt;
approach to use for GUIs:&lt;br&gt;
&lt;br&gt;
1) guidata -- seems you can both save and retrieve, so only&lt;br&gt;
one function is required&lt;br&gt;
2) setappdata/getappdata -- use one or the other to save and&lt;br&gt;
retrieve. Why would this be used above guidata?&lt;br&gt;
3) global variables -- this is another way to store&lt;br&gt;
application data&lt;br&gt;
4) guihandles -- what's the difference between this and&lt;br&gt;
calling guidata with a single argument?</description>
    </item>
    <item>
      <pubDate>Fri, 09 May 2008 16:15:05 -0400</pubDate>
      <title>Re: guidata returns empty array on CreateFcn callback?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169008#431270</link>
      <author>matt dash</author>
      <description>For all the gui's i've made, I've never used the createfcn's&lt;br&gt;
(since the &quot;runs during object creation&quot; is a little too&lt;br&gt;
ambiguous for my tastes).... But it sounds like you can&lt;br&gt;
instead modify the the gui opening function to do exactly&lt;br&gt;
what you need.&lt;br&gt;
&lt;br&gt;
As for the whole guidata business... I've made some really&lt;br&gt;
complicated gui's and I've never needed any command besides&lt;br&gt;
guidata. A few things to remember:&lt;br&gt;
&lt;br&gt;
If you are calling a function (for example, a callback) that&lt;br&gt;
uses &quot;handles&quot; within another function call guidata before&lt;br&gt;
(to save) and after (to reload): &lt;br&gt;
&lt;br&gt;
function outerfunction(hObject,evetdata,handles)&lt;br&gt;
...&lt;br&gt;
guidata(gcf,handles)&lt;br&gt;
myfunction(handles)&lt;br&gt;
handles=guidata(gcf)&lt;br&gt;
...&lt;br&gt;
%more lines&lt;br&gt;
%resave at end of function:&lt;br&gt;
guidata(gcf,handles)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Always remember to save handles at the end of your functions:&lt;br&gt;
&lt;br&gt;
guidata(gcf,handles)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
In general I also get better results by ONLY using guidata&lt;br&gt;
to save/load handles, as opposed to ever having handles as&lt;br&gt;
an input or output of a function (like guide does). </description>
    </item>
  </channel>
</rss>

