How do I save changes to handles after calling a helper function in GUI?

1 view (last 30 days)
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 Comment
Jan
Jan on 24 Jul 2012
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.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 24 Jul 2012
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.....

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!