How do I save changes to handles after calling a helper function in GUI?
조회 수: 6 (최근 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!