I think you are confused on how to add values to the guidata as now you are overwriting the values of OnOff by the pause values. Just use the debugging tool in matlab to step through your code line by line to see what is happening to your variables, especially starting from the onOffHandle
that said, you can check this with this code which should do what you want:
function Test_Button(hObject, eventdata, onOffHandle, varargin)
%Create the GUI
fig = figure;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create a pushbutton for On/Off Button
% Initial String is 'Off'
onOff = uicontrol(fig,'Style','pushbutton',...
'String','Off',...
'Position',[460 330 70 50],...
'Callback',@onOff_Callback);
% Create a pushbutton for Pause button
% Initial String is 'Pause'
pause = uicontrol(fig,'Style','pushbutton',...
'String','Pause',...
'Position',[460 280 70 50],...
'Callback',@pause_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create the handles for onOff button and Pause button
guiHandleData = guihandles(fig);
guiHandleData.stringsOnOff = {'On';'Off'};
guiHandleData.stringsPause = {'Pause';'Paused'};
guidata(fig, guiHandleData);
%%Function for onOff button
function varargout = onOff_Callback(a, eventdata)
% Get the current string
str = get(a,'String');
% See which string the current string matches with
ind = find(strcmp(str,guiHandleData.stringsOnOff));
% Switch to the other string
if ind == 1
set(a,'String',guiHandleData.stringsOnOff{2});
else
set(a,'String',guiHandleData.stringsOnOff{1});
end
end
%%Function for pause button
function varargout = pause_Callback(b, eventdata)
% Get the current string
st = get(b,'String');
% See which string the current string matches with
ind = find(strcmp(st,guiHandleData.stringsPause));
% Switch to the other string
if ind == 1
set(b,'String',guiHandleData.stringsPause{2});
else
set(b,'String',guiHandleData.stringsPause{1});
end
end
end