From: Travis on
I have a live updating editable text field in a GUI modeled after the one mentioned here - http://www.mathworks.com/matlabcentral/newsreader/view_thread/267096#736233

The problem I am having is that it doesn't update; unless I stop it in the editor, and then it works perfectly. I am using GUIDE to build the GUI.


function ProInterface_OpeningFcn(hObject, eventdata, handles, varargin)

handles.user=[];
set(handles.figure1,'KeyPressFcn',@Initials);
set(handles.UserName,'KeyPressFcn',{@Initials},'callback',{@UserName_Callback});


handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

function Initials(src,eventdata)

handles = guidata(src);

k = eventdata.Key;

if strcmp(k,'return')
pause(0.01)
return
end

if strcmp(k,'backspace')
handles.user = handles.user(1:end-1);

if (~isempty(handles.user) & length(handles.user) == 3) & ((handles.ABS & ~isempty(get(handles.AbsLoc,'String'))) | ...
((handles.FL & ~isempty(get(handles.FlLoc,'String'))) | (handles.FLABS ...
& ~isempty(get(handles.FlLoc,'String')) & ~isempty(get(handles.AbsLoc,'String')))...
& (handles.FLOG | handles.FL4 | handles.FL23) & ~isempty(get(handles.CoefLoc,'String'))));
set(handles.Process,'enable','on')
elseif isempty(get(handles.UserName,'string'))
handles.user='';
set(handles.Process,'enable','off')
else
set(handles.Process,'enable','off')
end
guidata(src, handles);
return
end

handles.user = [handles.user eventdata.Character];

if (~isempty(handles.user) & length(handles.user) == 3) & ((handles.ABS & ~isempty(get(handles.AbsLoc,'String'))) | ...
((handles.FL & ~isempty(get(handles.FlLoc,'String'))) | (handles.FLABS ...
& ~isempty(get(handles.FlLoc,'String')) & ~isempty(get(handles.AbsLoc,'String')))...
& (handles.FLOG | handles.FL4 | handles.FL23) & ~isempty(get(handles.CoefLoc,'String'))));
set(handles.Process,'enable','on')
elseif isempty(get(handles.UserName,'string'))
handles.user='';
set(handles.Process,'enable','off')
else
set(handles.Process,'enable','off')
end

guidata(src, handles);

handles.user is what I am trying to have update, with the actual editable field called handles.UserName. It is supposed to enable another button when the length of the string is 3 characters long. Like I said if I stop it in the editor, it works fine, but if I let it go, no matter what I type, handles.user does not get saved and remains empty.
From: Walter Roberson on
Travis wrote:
> I have a live updating editable text field in a GUI modeled after the
> one mentioned here -
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/267096#736233
>
> The problem I am having is that it doesn't update; unless I stop it in
> the editor, and then it works perfectly.

You probably need to add a drawnow() call after you make your update.
From: Travis on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hthamb$969$2(a)canopus.cc.umanitoba.ca>...
> Travis wrote:
> > I have a live updating editable text field in a GUI modeled after the
> > one mentioned here -
> > http://www.mathworks.com/matlabcentral/newsreader/view_thread/267096#736233
> >
> > The problem I am having is that it doesn't update; unless I stop it in
> > the editor, and then it works perfectly.
>
> You probably need to add a drawnow() call after you make your update.

Nope, didn't work :(
From: Matt Fig on
Travis emailed me the code so I could look at it. Part of the problem was that he was using the figure's keypressfcn instead of the uicontrol's keypressfcn. Even if he had implemented the GUI example referred to in a previous post, there was an error in that example which only showed in certain circumstances. The other thread has been updated with the error fixed for future reference.
From: per isakson on
"Travis " <sinusoid2(a)hotmail.com> wrote in message <hthcpa$bcn$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <hthamb$969$2(a)canopus.cc.umanitoba.ca>...
> > Travis wrote:
> > > I have a live updating editable text field in a GUI modeled after the
> > > one mentioned here -
> > > http://www.mathworks.com/matlabcentral/newsreader/view_thread/267096#736233
> > >
> > > The problem I am having is that it doesn't update; unless I stop it in
> > > the editor, and then it works perfectly.
> >
> > You probably need to add a drawnow() call after you make your update.
>
> Nope, didn't work :(

I think I encounter the same problem. In the thread "Subject: Editbox with picklist - how?" I provide a function that denomstrates the behavior. Yesterday I reported this to Mathworks tech support - calling it a bug.

/per