Why GUI closes when I use "handles=guidata(hGUI);" in ButtonDownFcn? (Using GUIDE)

1 view (last 30 days)
Good afternoon,
I'm trying to call a ButtonDownFcn when I click on a image that's updating (a frame of a video that is running). I need to use handles to plot a result in a statictext so I decide to write this:
function RawButtonDownFcn(hObject,eventdata)
handles=guidata(GUI_Gobi); %GUI_Gobi is my GUI
set(handles.Infopixel,'String','Has clicado en la imagen');
%Infopixel is a statictext. This is only a test, I want to do some stuff and then send the result to the static test.
When I run the GUI and click on the image, the image closes, the GUI closes, then the GUI open again and appears 'Has clicado en la imagen' in the statictext, but the video is closed.
The problem is this line "handles=guidata(GUI_Gobi);" If I write another code, for example:
function RawButtonDownFcn(hObject,eventdata)
a=5+10
It runs and display the result a=15
These are my files:
Thank you very much.
Alejandro.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Mar 2013
handles=guidata(GUI_Gobi)
means to run the function "GUI_Gobi" and apply the function "guidata" to the result.
You should use
handles = guidata( ancestor(hObject, 'figure') );

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!