<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485</link>
    <title>MATLAB Central Newsreader - ButtonDownFcn help</title>
    <description>Feed for thread: ButtonDownFcn help</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 29 Oct 2007 17:27:16 -0400</pubDate>
      <title>ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398880</link>
      <author>Matt Fig</author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
What exactly does this property do?  I want to make an edit&lt;br&gt;
box that has a default string in it when it first shows up.&lt;br&gt;
&amp;nbsp;When the user clicks inside the edit box, I want the&lt;br&gt;
default string to disappear, which I thought I could use the&lt;br&gt;
ButtonDownFcn to accomplish.  However, I cannot seem to make&lt;br&gt;
this ButtonDownFcn do anything at all.  What am I not&lt;br&gt;
understanding.  Here is one example.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
edt1 = uicontrol('style','edit','position',[30 30 90 20],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'string','String','ButtonDownFcn',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'set(edt1,''string'','' '')');&lt;br&gt;
&lt;br&gt;
I also tried a function name, like @clc for the&lt;br&gt;
ButtonDownFcn, but that didn't work either.&lt;br&gt;
&lt;br&gt;
Please tell me the correct way to use this ButtonDownFcn.  I&lt;br&gt;
know there may be another way to do what I want to do, but I&lt;br&gt;
also want to understand what this ButtonDownFcn does!  Thanks.</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 17:33:07 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398881</link>
      <author>Matt Fig</author>
      <description>I just tried the right click on the mouse and it worked! &lt;br&gt;
The left click is the one I want to have perform the same&lt;br&gt;
function.  Thanks.</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 17:51:25 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398882</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fg555k$j2e$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Matt Fig &amp;lt;spamanon@yahoo.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;edt1 = uicontrol('style','edit','position',[30 30 90 20],...&lt;br&gt;
&amp;gt;                 'string','String','ButtonDownFcn',...&lt;br&gt;
&amp;gt;                 'set(edt1,''string'','' '')');&lt;br&gt;
&lt;br&gt;
edt1 is not defined at the time the uicontrol() is executed,&lt;br&gt;
so your ButtonDownFcn cannot &quot;capture&quot; the value of edt1 to&lt;br&gt;
refer to it. Instead you are using the string form of callbacks,&lt;br&gt;
which I believe I have read is executed as if typed at the&lt;br&gt;
command line (implying that it would only have access to the&lt;br&gt;
global workspace.)&lt;br&gt;
&lt;br&gt;
See if this works:&lt;br&gt;
&lt;br&gt;
edt1 = uicontrol('style','edit','position',[30 30 90 20],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'string','String', ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'ButtonDownFcn', @(src,evt) set(src,'String', '') );&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;There are some ideas so wrong that only a very intelligent person&lt;br&gt;
&amp;nbsp;&amp;nbsp;could believe in them.&quot;                            -- George Orwell</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 17:53:14 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398884</link>
      <author>PB</author>
      <description>Den Mon, 29 Oct 2007 17:27:16 +0000 skrev Matt Fig:&lt;br&gt;
&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What exactly does this property do?  I want to make an edit box that has&lt;br&gt;
&amp;gt; a default string in it when it first shows up.&lt;br&gt;
&amp;gt;  When the user clicks inside the edit box, I want the&lt;br&gt;
&amp;gt; default string to disappear, which I thought I could use the&lt;br&gt;
&amp;gt; ButtonDownFcn to accomplish.  However, I cannot seem to make this&lt;br&gt;
&amp;gt; ButtonDownFcn do anything at all.  What am I not understanding.  Here is&lt;br&gt;
&amp;gt; one example.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; edt1 = uicontrol('style','edit','position',[30 30 90 20],...&lt;br&gt;
&amp;gt;                  'string','String','ButtonDownFcn',...&lt;br&gt;
&amp;gt;                  'set(edt1,''string'','' '')');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I also tried a function name, like @clc for the ButtonDownFcn, but that&lt;br&gt;
&amp;gt; didn't work either.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Please tell me the correct way to use this ButtonDownFcn.  I know there&lt;br&gt;
&amp;gt; may be another way to do what I want to do, but I also want to&lt;br&gt;
&amp;gt; understand what this ButtonDownFcn does!  Thanks.&lt;br&gt;
&lt;br&gt;
Matt, you are doing it right. It just doesn't behave the way you expect &lt;br&gt;
it to. To execute the ButtonDownFcn, either click in a five-pixel border &lt;br&gt;
around the uicontrol or right-click inside the control itself. ( I can't &lt;br&gt;
find a doc-reference but I know this is the way it works.)&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
&lt;br&gt;
PB</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 17:55:24 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398885</link>
      <author>Matt Fig</author>
      <description>OOps, upon a more careful reading of the properties,&lt;br&gt;
ButtonDownFcn does what it is supposed to do.  I would still&lt;br&gt;
like to either have a left click clear the string or&lt;br&gt;
initialize the string in a highlighted state so that once&lt;br&gt;
the user starts typing the default string disappears and the&lt;br&gt;
new one replaces it, if anyone knows how to do this.</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 18:53:47 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398896</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fg56qc$f26$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Matt Fig &amp;lt;spamanon@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;OOps, upon a more careful reading of the properties,&lt;br&gt;
&amp;gt;ButtonDownFcn does what it is supposed to do.  I would still&lt;br&gt;
&amp;gt;like to either have a left click clear the string or&lt;br&gt;
&amp;gt;initialize the string in a highlighted state so that once&lt;br&gt;
&amp;gt;the user starts typing the default string disappears and the&lt;br&gt;
&amp;gt;new one replaces it, if anyone knows how to do this.&lt;br&gt;
&lt;br&gt;
You will have to modify the Java properties for this.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;Is there any thing whereof it may be said, See, this is new? It hath&lt;br&gt;
&amp;nbsp;&amp;nbsp;been already of old time, which was before us.&quot;    -- Ecclesiastes</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 22:15:07 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398922</link>
      <author>Yair Altman</author>
      <description>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in&lt;br&gt;
message &amp;lt;fg5a7r$4he$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt; In article &amp;lt;fg56qc$f26$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; Matt Fig &amp;lt;spamanon@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;OOps, upon a more careful reading of the properties,&lt;br&gt;
&amp;gt; &amp;gt;ButtonDownFcn does what it is supposed to do.  I would still&lt;br&gt;
&amp;gt; &amp;gt;like to either have a left click clear the string or&lt;br&gt;
&amp;gt; &amp;gt;initialize the string in a highlighted state so that once&lt;br&gt;
&amp;gt; &amp;gt;the user starts typing the default string disappears and the&lt;br&gt;
&amp;gt; &amp;gt;new one replaces it, if anyone knows how to do this.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You will have to modify the Java properties for this.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
...and here's how (note: undocumented/unsupported by MathWorks):&lt;br&gt;
&lt;br&gt;
1. download my FindJObj from the File Exchange:&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14317&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14317&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
2. run the following:&lt;br&gt;
edt1=uicontrol('style','edit',...); %no need to set&lt;br&gt;
ButtonDownFcn&lt;br&gt;
jedt1=findjobj(edt1,'nomenu'); %get underlying java object&lt;br&gt;
cbStr='set(gcbo,''text'','''');set(gcbo,''MouseClickedCallback'',[])';&lt;br&gt;
set(jedt1,'MouseClickedCallback',cbStr);&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
&lt;a href=&quot;http://ymasoftware.com&quot;&gt;http://ymasoftware.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 22:26:50 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398924</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fg5m1b$a7g$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Yair Altman &amp;lt;altmanyDEL@gmailDEL.comDEL&amp;gt; wrote:&lt;br&gt;
&amp;gt;roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in&lt;br&gt;
&amp;gt;message &amp;lt;fg5a7r$4he$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; In article &amp;lt;fg56qc$f26$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt;&amp;gt; Matt Fig &amp;lt;spamanon@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;I would still&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;like to either have a left click clear the string or&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;initialize the string in a highlighted state so that once&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;the user starts typing the default string disappears and the&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt;new one replaces it, if anyone knows how to do this.&lt;br&gt;
&lt;br&gt;
&amp;gt;...and here's how (note: undocumented/unsupported by MathWorks):&lt;br&gt;
&lt;br&gt;
&amp;gt;1. download my FindJObj from the File Exchange:&lt;br&gt;
&amp;gt;&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14317&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14317&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&amp;gt;2. run the following:&lt;br&gt;
&amp;gt;edt1=uicontrol('style','edit',...); %no need to set&lt;br&gt;
&amp;gt;ButtonDownFcn&lt;br&gt;
&amp;gt;jedt1=findjobj(edt1,'nomenu'); %get underlying java object&lt;br&gt;
&amp;gt;cbStr='set(gcbo,''text'','''');set(gcbo,''MouseClickedCallback'',[])';&lt;br&gt;
&amp;gt;set(jedt1,'MouseClickedCallback',cbStr);&lt;br&gt;
&lt;br&gt;
Hmmm, that appears to me to clear the mouse click callback after&lt;br&gt;
clearing the edit field. If so, then the callback would somehow&lt;br&gt;
have to be reprimed after the field lost focus. Matt wasn't clear&lt;br&gt;
on what he would like to have happen after the first time; my own&lt;br&gt;
interpretation is that he wanted mouse left-click to clear the&lt;br&gt;
string each time. Which leads to difficulty if the user wants to&lt;br&gt;
use the mouse to reposition within the string for editting purposes.&lt;br&gt;
&lt;br&gt;
Matt? What do you expect after the first firing?&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Beware of bugs in the above code; I have only proved it correct,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;not tried it.&quot;                                    -- Donald Knuth</description>
    </item>
    <item>
      <pubDate>Mon, 29 Oct 2007 23:45:57 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398932</link>
      <author>Yair Altman</author>
      <description>&amp;gt; Hmmm, that appears to me to clear the mouse click callback &lt;br&gt;
&amp;gt; after clearing the edit field.&lt;br&gt;
&lt;br&gt;
exactly - on purpose&lt;br&gt;
&lt;br&gt;
&amp;gt; If so, then the callback would somehow&lt;br&gt;
&amp;gt; have to be reprimed after the field lost focus.&lt;br&gt;
&lt;br&gt;
This can easily be done by setting the MouseClickedCallback&lt;br&gt;
in FocusLostCallback (I forget the exact name but it should&lt;br&gt;
be pretty close), and clearing it in FocusGainedCallback. Or&lt;br&gt;
some similar variation, you get the drift.&lt;br&gt;
&lt;br&gt;
&amp;gt; Matt wasn't clear on what he would like to have happen&lt;br&gt;
&amp;gt; after the first time; my own interpretation is that he &lt;br&gt;
&amp;gt; wanted mouse left-click to clear the string each time. &lt;br&gt;
&amp;gt; Which leads to difficulty if the user wants to use the &lt;br&gt;
&amp;gt; mouse to reposition within the string for editting purposes.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Matt? What do you expect after the first firing?&lt;br&gt;
&lt;br&gt;
In most non-Matlab implementations that I've seen, following&lt;br&gt;
the first clearing the data was considered &quot;tainted&quot; and&lt;br&gt;
never cleared again, even after losing focus. Of course,&lt;br&gt;
this is a matter of usability and requirements, and these&lt;br&gt;
are just my 2 cents. To clear the data each time, one can&lt;br&gt;
use the Focus callback as stated above. &lt;br&gt;
&lt;br&gt;
The above Java callbacks, along with some ~30 other standard&lt;br&gt;
uicontrol callbacks are so powerful: The above example could&lt;br&gt;
never be done with the standard Matlab callbacks, and yet is&lt;br&gt;
so easy to achieve using the Java ones. It's such a pity&lt;br&gt;
that MathWorks does not expose them in the regular Matlab&lt;br&gt;
(HG) interface. Maybe someone will pick up the ball for&lt;br&gt;
R2008a... Bill? anyone?&lt;br&gt;
&lt;br&gt;
Yair Altman</description>
    </item>
    <item>
      <pubDate>Tue, 30 Oct 2007 01:10:31 -0400</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#398946</link>
      <author>Matt Fig</author>
      <description>The action I wish for is this:  the first mouse click clears&lt;br&gt;
the form of it's default string, any following mouse clicks&lt;br&gt;
place the cursor where the pointer points.  &lt;br&gt;
I would also settle for the edit box to come up with the&lt;br&gt;
default string highlighted so that as soon as the user&lt;br&gt;
started typing, it would be overwritten anyway.  That way&lt;br&gt;
the user wouldn't have to click in the first place and I&lt;br&gt;
wouldn't have to program in all the buttondownfcn&lt;br&gt;
manipulations!  Thanks guys.</description>
    </item>
    <item>
      <pubDate>Wed, 16 Feb 2011 23:15:05 -0500</pubDate>
      <title>Re: ButtonDownFcn help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158485#819808</link>
      <author>Jeremy </author>
      <description>Hey Matt - Did you ever find a good solution to this problem? This is exactly what I'm trying to achieve now. Thanks!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Matt Fig&quot; wrote in message &amp;lt;fg60a7$mr9$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; The action I wish for is this:  the first mouse click clears&lt;br&gt;
&amp;gt; the form of it's default string, any following mouse clicks&lt;br&gt;
&amp;gt; place the cursor where the pointer points.  &lt;br&gt;
&amp;gt; I would also settle for the edit box to come up with the&lt;br&gt;
&amp;gt; default string highlighted so that as soon as the user&lt;br&gt;
&amp;gt; started typing, it would be overwritten anyway.  That way&lt;br&gt;
&amp;gt; the user wouldn't have to click in the first place and I&lt;br&gt;
&amp;gt; wouldn't have to program in all the buttondownfcn&lt;br&gt;
&amp;gt; manipulations!  Thanks guys.</description>
    </item>
  </channel>
</rss>

