Hi,
I know that this is probably a simple problem but I am new to Matlab GUI's and basically want to get the old value which used to be stored in the text box to replace the value which has just been entered. E.g.
Text box contains a valid string,
User enters invalid string,
Callback func, validates input and realises new input is an error and reverts to the old previous value.
How should this be implemented or done? Atm I am just using the get and set property values.
Below is some sample code:
function sampledist_Callback(hObject, eventdata, handles)
% hObject handle to sampledist (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sampledist as text
% str2double(get(hObject,'String')) returns contents of sampledist as a double
input = str2double(get(hObject,'String'));
if(input < 0 || input > 500)
errordlg('Sampled Dist. must be > 0 and < 500','Sample Dist - Input Error');
set(handles.sampledist,'String',['10']); %<--- I would like this value 10 to be the previous entry!
guidata(hObject,handles);
else
set(handles.sampledist,'String',['',input]);
guidata(hObject,handles);
end