I am trying to make a function/GUI that is put in nine buttons' callback function area. The function references the string of the button that was pressed and changes it. In the function, how do I make it so that I have a button tag to reference?
Here is my function code
function handles = buttonPress(hObject,handles)if handles.String ~= ' ' handles.BackgroundColor=[1 0 0]; hold on handles.BackgroundColor = [1 1 1];else if handles.whoseTurn.String=='o' handles.String='o'; handles.turnNumber.String=str2num(handles.turnNumber.String)+1; handles.whoseTurn.String='x'; elseif handles.whoseTurn.String=='x' handles.String='x'; handles.turnNumber.String=str2num(handles.turnNumber.String)+1; handles.whoseTurn.String='o'; endendend
I want to make it so that handles.TAG.String is used for every button, but I don't know how to make the tag change.
Best Answer