I have a set of push-buttons in a figure designed in GUIDE and I want to assign one single function as their callback functions. But there is no combo-box to choose my function from in the property inspector, and when I select all buttons and click Callback from View Callbacks menu it creates multiple callback functions. Same behavior when I hit the I-DON'T-KNOW-WHAT-TO-CALL button in the property inspector.
I can handle this with some coding in OpeningFcn
like what described here or just with calling set(handle, 'method')
, but I really prefer to do it in the designing environment.
You can edit the Callback
value within the Property Inspector. By default, it will be a custom callback for that uicontrol, but you can change it to be whatever you want.
So for me, for two push buttons they are something like the following by default:
@(hObject,eventdata)mygui('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
@(hObject,eventdata)mygui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Just copy the value of one into the other and they will have the same callback.
Alternately, you can make them have a completely different callback by specifying your own value.