In a GUIDE, is it possible to reduce the number of button callback functions?

1 Ansicht (letzte 30 Tage)
For a GUIDE with 2 buttons, both calling the same function but with different function-inputs. Eg:
function radiobutton1_Callback(hObject, eventdata, handles)
if get(hObject,'Value'), disp('A'); end
function radiobutton2_Callback(hObject, eventdata, handles)
if get(hObject,'Value'), disp('B'); end
Is it possible to call the same function with different inputs like this:
function radiobutton_ALL_Callback(hObject,str)
if get(hObject,'Value'), disp(str); end
Avoid copy/paste is the purpose.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Mär. 2013
GUIDE will not want to do this. GUIDE puts its own callback string in that fetches the handles and then calls the real callback under the assumption that it will use object / event / handles as the calling sequence. I have not used GUIDE enough to know whether you can override GUIDE for this purpose.
  1 Kommentar
yosey
yosey am 24 Mär. 2013
Thank you. I guess i shouldn't bungle in GUIDE standards.
I'll write the 'str' to UserData property or try assignments with tag, string and style.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by