saving new handles in callback using guidata
1 次查看(过去 30 天)
显示 更早的评论
Hello
I have a problem of saving handles I created in my callback function and updating my main handle using guidata. Example of my code below. I'm doing this programmatically.
function myCallbackFunction(hObject, eventdata, handles, varargin)
myhandles = guidata(hObject);
%do something
myhandles.newHandle = [1 2 3 4]; %Make a new Handle
guidata(hObject, myhandles)
end
I didn't put everything the the example, but tried I created a new handle myhandles.newHandle which is and array. After updating everything using guidata, I check my main handle h in my main function there is no such handle h.newHandle. If built my gui using nested functions this problem doesn't occur only when I have all my functions setup as sub functions. Is the only solution to this problem is I have to create a handle h.newHandle in my main function and so when i call guidata(hObject) the handle is there for me to make changes
0 个评论
回答(1 个)
Walter Roberson
2012-4-17
In your main function you need to use
handles = guidata(gcf);
in order to update the main function's knowledge of the contents of "handles".
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!