How do I save changes to handles after calling a helper function in GUI?
1 次查看(过去 30 天)
显示 更早的评论
I know that to save GUI information you do guidata(hObject, handles) after a change however this does not seem to work when you call a helper function within a callback. For instance, I have a toolbar icon and a menu tab to let the user open an image. Since both are practically the same exact code I thought I would write them as wrapper functions to a helper funciton Open() which takes as parameters (hOjbect, handles). When I call guidata(hObject, handles) in each individual callback it works perfectly but with the same exact code transferred to the helper function (including the guidata(hObject, handles)) it does not. WHY DOESN'T MATLAB ALLOW POINTERS!!!!!
1 个评论
Jan
2012-7-24
Matlab uses a copy on write strategie: As long as the values are not changes, shared copies are used, which could be seen as a kind of pointer.
回答(1 个)
Image Analyst
2012-7-24
Try returning handles as an output to the functions if you change handles within the function. I.e
function handles = MyFunction(handles, input1, input2, input3) % Function has code that makes use of handles.....
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!