saving new handles in callback using guidata
7 ビュー (過去 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 で Model, Block, and Port Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!