function InvalidateEditControl(hControl,revertText)
% Invalidate the entry in an edit uicontrol or any other uicontrol that has
% user-entered text and supports evaluation of that text.

%   Copyright 2014 The MathWorks, Inc.

% Show color-fading highlight.
%
% Must retain object so the fading persists after we exit this method.
%
% An overwrite will delete the last object and that's what we want.

hh = getappdata(hControl,'InvalidateEditControl_FadeTimer');
if isempty(hh)
    hh = dialogmgr.ControlColorFader(hControl);
    setappdata(hControl,'InvalidateEditControl_FadeTimer',hh);
end
start(hh);

% Put back previous text, if supplied
if nargin>1
    hControl.String = revertText;
end
