Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!news.aset.psu.edu!news.cse.psu.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: ButtonDownFcn help
Date: Mon, 29 Oct 2007 17:51:25 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 22
Message-ID: <fg56it$4h$1@canopus.cc.umanitoba.ca>
References: <fg555k$j2e$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1193680285 145 192.70.172.160 (29 Oct 2007 17:51:25 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Mon, 29 Oct 2007 17:51:25 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:435109



In article <fg555k$j2e$1@fred.mathworks.com>,
Matt Fig <spamanon@yahoo.com> wrote:

>edt1 = uicontrol('style','edit','position',[30 30 90 20],...
>                 'string','String','ButtonDownFcn',...
>                 'set(edt1,''string'','' '')');

edt1 is not defined at the time the uicontrol() is executed,
so your ButtonDownFcn cannot "capture" the value of edt1 to
refer to it. Instead you are using the string form of callbacks,
which I believe I have read is executed as if typed at the
command line (implying that it would only have access to the
global workspace.)

See if this works:

edt1 = uicontrol('style','edit','position',[30 30 90 20],...
                 'string','String', ...
                 'ButtonDownFcn', @(src,evt) set(src,'String', '') );
-- 
  "There are some ideas so wrong that only a very intelligent person
  could believe in them."                            -- George Orwell