Reputation: 435
I am trying to pushbutton callback in an another pushbutton callback, but I am having problems:
Here is what i am trying to do:
C_N_Callback(hObject,eventdata, handles)
RN_Callback(handles, [], []);
I tried this but gave this error:
Attempt to reference field of non-structure array.
Inside RN_Callback
at first step where it is doing getappdata
.
I also tried this:
C_N_Callback(hObject,eventdata, handles)
RN_Callback(hObject,eventdata, handles);
This did not give error but when i run the GUI it keeps doing the procedure in RN_Callback
(i guess on refresh).
Upvotes: 1
Views: 5073
Reputation: 20915
Perhaps RN_Callback
is using the reference to hObject
. Just to remind you, hObject
is the object on which the callback is being called. So in your case, it will be C_N
, which will be passed to RN_Callback
instead of RN
.
In that case, the code will be wrong, because it expects a GUI object of one type, but gets another. For example:
function RN_Callback(hObject,eventdata, handles)
set(hObject,'String','This is me!');
end
function C_N_Callback(hObject,eventdata, handles)
RN_Callback(hObject,eventdata, handles);
end
Clicking on on RN
will change its string. But clicking on C_N
will change C_N
, instead of RN
as you might have expected.
Upvotes: 1