<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102</link>
    <title>MATLAB Central Newsreader - Listbox mousedown problems</title>
    <description>Feed for thread: Listbox mousedown problems</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The 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>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 12 May 2008 12:30:31 -0400</pubDate>
      <title>Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431539</link>
      <author>helper </author>
      <description>Ok, I give up...&lt;br&gt;
&lt;br&gt;
I can't even begin to list all the dozens of things I've &lt;br&gt;
tried to make this work, but this problem is fighting back &lt;br&gt;
like I killed its pet hamster.&lt;br&gt;
&lt;br&gt;
I have a listbox uicontrol and an edittext uicontrol &lt;br&gt;
working in conjuction to allow me to change the elements of &lt;br&gt;
the listbox.  The following is code which reproduces it:&lt;br&gt;
&lt;br&gt;
%-----------------------------------------%&lt;br&gt;
function ListBoxTest&lt;br&gt;
figure&lt;br&gt;
hListbox = uicontrol('style','listbox',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'pos',[20 20 100 100],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'String',{'a','b','c'},...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'backg','w',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'Callback',@(x,y)Listbox_Callback);&lt;br&gt;
hEditText = uicontrol('style','edit',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'pos',[20 130 100 20],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'String','',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'backg','w',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'Callback',@(x,y)EditText_Callback);&lt;br&gt;
Listbox_Callback&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;function Listbox_Callback&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(hEditText,'String',str{val})&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;function EditText_Callback&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newStr = get(hEditText,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str{val} = newStr;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% pause(1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(hListbox,'String',str)&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
%-----------------------------------------%&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Now, typing in the editbox changes the elements of the list &lt;br&gt;
and everything is working fine there.&lt;br&gt;
&lt;br&gt;
To see my problem, perform the following steps:&lt;br&gt;
&lt;br&gt;
1. Select element 1 in the listbox&lt;br&gt;
2. Click in the editbox and edit the value&lt;br&gt;
3. Click element 3 in the listbox&lt;br&gt;
&lt;br&gt;
You will see that the listbox jumps back to element 1, and &lt;br&gt;
the user must click on the listbox again to change the &lt;br&gt;
value.&lt;br&gt;
&lt;br&gt;
The problem is caused by the fact that the editbox's &lt;br&gt;
callback changes the "String" property of the listbox, thus &lt;br&gt;
cancelling any mousedown that has previously occurred on &lt;br&gt;
the listbox.&lt;br&gt;
&lt;br&gt;
Try uncommenting the PAUSE command, and in step 3 above, &lt;br&gt;
hold the mouse button down on element 3.  You will see the &lt;br&gt;
SET command altering the listbox selection.&lt;br&gt;
&lt;br&gt;
The root of the problem is that the listbox's callback &lt;br&gt;
doesn't fire until the mouseup, however the editbox's &lt;br&gt;
callback will fire on the mousedown.&lt;br&gt;
&lt;br&gt;
Things I have tried:&lt;br&gt;
&lt;br&gt;
1. Using the listbox's "ButtonDownFcn" rather than &lt;br&gt;
its "Callback", however this doesn't work for left-click &lt;br&gt;
when "Enable" is "on".&lt;br&gt;
&lt;br&gt;
2. Using the FEX's FINDJOBJ function to be able to get a &lt;br&gt;
callback when a mousedown event occurs on the listbox.  &lt;br&gt;
However, setting the "MousePressedCallback" (and many other &lt;br&gt;
callback options) doesn't seem to fire when the mouse is &lt;br&gt;
pressed.  This is probably the solution, but I can't seem &lt;br&gt;
to get it to work.&lt;br&gt;
&lt;br&gt;
3. Using MANY methods for the editbox's callback to &lt;br&gt;
recognize it has been fired by a mousedown event on the &lt;br&gt;
listbox so it can avoid setting the string property until &lt;br&gt;
the listbox's callback has fired.  Note that:&lt;br&gt;
&amp;nbsp;&amp;nbsp;a) checking the PointerPostion property of the root &lt;br&gt;
object to see if it is over the listbox doesn't help &lt;br&gt;
because the callback could have fired from a keypress (tab &lt;br&gt;
or enter).&lt;br&gt;
&amp;nbsp;&amp;nbsp;b)  The currentcharacter property (of the figure) will &lt;br&gt;
tell me that the enter key was pressed, however it will not &lt;br&gt;
tell me that the tab key was pressed.&lt;br&gt;
&amp;nbsp;&amp;nbsp;c) checking the CurrentObject doesn't work because a &lt;br&gt;
mousedown event on the listbox doesnt change the &lt;br&gt;
CurrentObject.&lt;br&gt;
&amp;nbsp;&amp;nbsp;d) e) f) g) h) ... z)  I can go on &lt;br&gt;
&lt;br&gt;
&amp;nbsp;&lt;br&gt;
I have enjoyed battling this killer rabbit, however it has &lt;br&gt;
beaten me badly and I am crawling outta the cave dragging &lt;br&gt;
my shield behind me.&lt;br&gt;
&lt;br&gt;
Does anyone feel like whacking a rabbit?&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 12 May 2008 17:11:38 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431605</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g09d97$ir0$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
helper  &amp;lt;spamless@nospam.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;To see my problem, perform the following steps:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;1. Select element 1 in the listbox&lt;br&gt;
&amp;gt;2. Click in the editbox and edit the value&lt;br&gt;
&amp;gt;3. Click element 3 in the listbox&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;You will see that the listbox jumps back to element 1, and &lt;br&gt;
&amp;gt;the user must click on the listbox again to change the &lt;br&gt;
&amp;gt;value.&lt;br&gt;
&lt;br&gt;
Did you try recording the Value parameter of the listbox before&lt;br&gt;
the change and then setting the Value of the listbox after&lt;br&gt;
the String has changed? The Value parameter controls which line&lt;br&gt;
of the listbox is the current line.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;"There is nothing so bad but it can masquerade as moral."&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-- Walter Lippmann&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 00:04:04 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431691</link>
      <author>helper </author>
      <description>&amp;gt; Did you try recording the Value parameter of the listbox &lt;br&gt;
before&lt;br&gt;
&amp;gt; the change and then setting the Value of the listbox after&lt;br&gt;
&amp;gt; the String has changed? The Value parameter controls &lt;br&gt;
which line&lt;br&gt;
&amp;gt; of the listbox is the current line.&lt;br&gt;
&lt;br&gt;
That will not work for me.&lt;br&gt;
&lt;br&gt;
The problem is that although the mousedown event changes &lt;br&gt;
which element appears to be selected on the listbox, and &lt;br&gt;
causes the editbox callback to fire, it does not change &lt;br&gt;
the "Value" property in MATLAB.  The "Value" property does &lt;br&gt;
not change until the mouseup event.&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 04:09:03 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431702</link>
      <author>matt dash</author>
      <description>"helper " &amp;lt;spamless@nospam.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g0altk$221$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Did you try recording the Value parameter of the listbox &lt;br&gt;
&amp;gt; before&lt;br&gt;
&amp;gt; &amp;gt; the change and then setting the Value of the listbox after&lt;br&gt;
&amp;gt; &amp;gt; the String has changed? The Value parameter controls &lt;br&gt;
&amp;gt; which line&lt;br&gt;
&amp;gt; &amp;gt; of the listbox is the current line.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; That will not work for me.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The problem is that although the mousedown event changes &lt;br&gt;
&amp;gt; which element appears to be selected on the listbox, and &lt;br&gt;
&amp;gt; causes the editbox callback to fire, it does not change &lt;br&gt;
&amp;gt; the "Value" property in MATLAB.  The "Value" property does &lt;br&gt;
&amp;gt; not change until the mouseup event.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
This sounds a lot like my problems of trying to make a&lt;br&gt;
scrollbar that you can click and drag.... same thing, you&lt;br&gt;
can't do it with the window motion function because the&lt;br&gt;
value doesn't update until the upbutton. I got around it by&lt;br&gt;
using the java callbacks. You might give that a try if&lt;br&gt;
you're desperate, though I'm not sure what kind of java&lt;br&gt;
callbacks a listbox has. (I used findjobj on the file&lt;br&gt;
exchange and worked from there.)&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 04:29:03 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431704</link>
      <author>helper </author>
      <description>&amp;gt; This sounds a lot like my problems of trying to make a&lt;br&gt;
&amp;gt; scrollbar that you can click and drag.... same thing, you&lt;br&gt;
&amp;gt; can't do it with the window motion function because the&lt;br&gt;
&amp;gt; value doesn't update until the upbutton. I got around it &lt;br&gt;
by&lt;br&gt;
&amp;gt; using the java callbacks. You might give that a try if&lt;br&gt;
&amp;gt; you're desperate, though I'm not sure what kind of java&lt;br&gt;
&amp;gt; callbacks a listbox has. (I used findjobj on the file&lt;br&gt;
&amp;gt; exchange and worked from there.)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Check bullet #2 on my original post.&lt;br&gt;
&lt;br&gt;
I tried this, but I can't seem to actually get the &lt;br&gt;
MousePressedCallback to fire.  Some of the java callbacks &lt;br&gt;
will fire (e.g., MouseMovedCallback, &lt;br&gt;
PropertyChangedCallback), but some won't (e.g., &lt;br&gt;
MousePressedCallback, MouseReleasedCallback, &lt;br&gt;
MouseClickedCallback).  I tried:&lt;br&gt;
&lt;br&gt;
hListJava = findjobj(hListbox);&lt;br&gt;
hListJava.MousePressedCallback =...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;@(x,y)disp('Mouse Pressed');&lt;br&gt;
&lt;br&gt;
However, no callback fires.  Any ideas what I am doing &lt;br&gt;
wrong?&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 11:32:02 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431763</link>
      <author>Malcolm Lidierth</author>
      <description>Why use anonymous functions?&lt;br&gt;
This seems to work - or have I missed the point?&lt;br&gt;
&lt;br&gt;
function ListBoxTest&lt;br&gt;
figure&lt;br&gt;
hListbox = uicontrol('style','listbox',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'pos',[20 20 100 100],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'String',{'a','b','c'},...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'backg','w',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'Callback',@Listbox_Callback);&lt;br&gt;
hEditText = uicontrol('style','edit',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'pos',[20 130 100 20],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'String','',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'backg','w',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;'Callback',@EditText_Callback);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;function Listbox_Callback(hObject, EventData)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(hEditText,'String',str{val})&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;function EditText_Callback(hObject, EventData)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newStr = get(hEditText,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str{val} = newStr;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% pause(1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(hListbox,'String',str)&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 12:03:45 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431774</link>
      <author>helper </author>
      <description>"Malcolm Lidierth" &amp;lt;ku.ca.lck@htreidil.mloclam&amp;gt; wrote in &lt;br&gt;
message &amp;lt;g0bu7i$jkr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; Why use anonymous functions?&lt;br&gt;
&amp;gt; This seems to work - or have I missed the point?&lt;br&gt;
&lt;br&gt;
You have missed it Malcom.  Try out the reproduction steps &lt;br&gt;
in my first post, and you'll see where I am having my &lt;br&gt;
problem.&lt;br&gt;
&lt;br&gt;
By the way, I use anonymous functions so I don't have to &lt;br&gt;
have the unused inputs to all of my callbacks.  Notice the &lt;br&gt;
little orange squigglies under the inputs arguments within &lt;br&gt;
the MATLAB editor.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 14:27:03 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431807</link>
      <author>Malcolm Lidierth</author>
      <description>OK - I think I now see your problem - but I can't help much.&lt;br&gt;
&lt;br&gt;
For the findjobj above you may need to dig deeper through &lt;br&gt;
the hierarchy&lt;br&gt;
&lt;br&gt;
K&amp;gt;&amp;gt; ans = findjobj(hListbox);&lt;br&gt;
returns a ScrollPane&lt;br&gt;
&lt;br&gt;
K&amp;gt;&amp;gt; get(ans.getViewport(), 'View')&lt;br&gt;
&lt;br&gt;
gets you to the &lt;br&gt;
com.mathworks.hg.peer.ListboxPeer$UicontrolList&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 15:24:03 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431825</link>
      <author>matt dash</author>
      <description>Hah, Ok, having completely ignored your first post I feel&lt;br&gt;
obligated to help now. See if this is what you're looking for:&lt;br&gt;
&lt;br&gt;
For me this does what I think you want, with the possible&lt;br&gt;
exception that it updates as you type and not when you're&lt;br&gt;
done typing, but maybe that's ok with you. The trick is to&lt;br&gt;
use the callbacks of the editbox, not the list box. &lt;br&gt;
&lt;br&gt;
function ListBoxTest&lt;br&gt;
figure&lt;br&gt;
handles.hListbox = uicontrol('style','listbox',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'pos',[20 20 100 100],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'String',{'a','b','c'},...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'backg','w',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Callback',@Listbox_Callback);&lt;br&gt;
handles.hEditText = uicontrol('style','edit',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'pos',[20 130 100 20],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'String','',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'backg','w',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Callback',@EditText_Callback);&lt;br&gt;
&lt;br&gt;
guidata(gcf,handles)&lt;br&gt;
&lt;br&gt;
jEdit=findjobj(handles.hEditText);&lt;br&gt;
jEdit.KeyTypedCallback=@imtyping;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function Listbox_Callback(hObject, EventData)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(handles.hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(handles.hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.hEditText,'String',str{val})&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function EditText_Callback(hObject, EventData)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(handles.hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(handles.hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newStr = get(handles.hEditText,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str{val} = newStr;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% pause(1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.hListbox,'String',str)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function imtyping(src,eventdata)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;jEdit=src;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string=jEdit.getText;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;handles=guidata(gcf);     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val = get(handles.hListbox,'Value');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = get(handles.hListbox,'String');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newStr = char(string);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;str{val} = newStr;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.hListbox,'String',str);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;drawnow&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 15:52:04 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431836</link>
      <author>helper </author>
      <description>Good idea to have the typing within the edit box update the &lt;br&gt;
listbox string rather than the callback.  This does indeed &lt;br&gt;
solve this problem.&lt;br&gt;
&lt;br&gt;
Based on Malcom's post, prior to seeing yours, I understood &lt;br&gt;
I was using the wrong java object.  Using the correct java &lt;br&gt;
object,&lt;br&gt;
&lt;br&gt;
hListJava = findjobj(hListbox);&lt;br&gt;
hListJava = get(hListJava.Viewport,'View');&lt;br&gt;
&lt;br&gt;
I am able to know the listbox value based on the mousedown &lt;br&gt;
event and, thus using Walter's idea, "store" the listbox &lt;br&gt;
value prior to setting the "String".&lt;br&gt;
&lt;br&gt;
What is interesting here is that upon the mousedown event &lt;br&gt;
the Java object changes its "SelectionIndex" value and &lt;br&gt;
MATLAB fires the EditBox callback.  Within the editbox &lt;br&gt;
callback, MATLAB's "Value" property retains the original &lt;br&gt;
listbox value (until the mouseup event), while the Java &lt;br&gt;
object retains the new listbox value.  Therefore, I will &lt;br&gt;
simultaneously have acces to both and not need to "store" &lt;br&gt;
the value.&lt;br&gt;
&lt;br&gt;
One problem, however, is that I do not like the way &lt;br&gt;
FINDJOBJ "cycles" through all the Java objects to find the &lt;br&gt;
object.  It activates and shows all the menu items, and &lt;br&gt;
seems to take a long time to find the requested object. &lt;br&gt;
&lt;br&gt;
Isn't there a better way for me to get a handle to this &lt;br&gt;
java object?&lt;br&gt;
&lt;br&gt;
Regardless, I think I might implement Matt's "imtyping" &lt;br&gt;
idea since it looks cool for the user.  Also, I can do &lt;br&gt;
something similar to this method without having to resort &lt;br&gt;
to using the Java object and instead use MATLAB's &lt;br&gt;
KeyPressFcn.  Of course, I will have to accumulate all &lt;br&gt;
keypresses myself (since MATLAB's editbox doesn't update &lt;br&gt;
the "String" property until the callback), but I have done &lt;br&gt;
this successfully before.&lt;br&gt;
&lt;br&gt;
Thanks all for your help.  You did a fine job killing my &lt;br&gt;
killer rabbit.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 16:34:02 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431848</link>
      <author>Malcolm Lidierth</author>
      <description>&amp;gt; Isn't there a better way for me to get a handle to this &lt;br&gt;
&amp;gt; java object?&lt;br&gt;
&lt;br&gt;
You could create the java object directly using &lt;br&gt;
javacomponent. Yair's uicomponent and my own jcontrol help &lt;br&gt;
with that, both on ML Central. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;Of course, I will have to accumulate all &lt;br&gt;
keypresses myself....&lt;br&gt;
&lt;br&gt;
Noth that, if you use the CallbackFcn(hObject, EventData) &lt;br&gt;
form, the individual key information should be available in &lt;br&gt;
EventData&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 16:35:05 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#431849</link>
      <author>Malcolm Lidierth</author>
      <description>&amp;gt; Isn't there a better way for me to get a handle to this &lt;br&gt;
&amp;gt; java object?&lt;br&gt;
&lt;br&gt;
You could create the java object directly using &lt;br&gt;
javacomponent. Yair's uicomponent and my own jcontrol help &lt;br&gt;
with that, both on ML Central. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;Of course, I will have to accumulate all &lt;br&gt;
keypresses myself....&lt;br&gt;
&lt;br&gt;
Noth that, if you use the CallbackFcn(hObject, EventData) &lt;br&gt;
form, the individual key information should be available in &lt;br&gt;
EventData&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 20:12:02 -0400</pubDate>
      <title>Re: Listbox mousedown problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169102#445765</link>
      <author>Yair Altman</author>
      <description>"helper " &amp;lt;spamless@nospam.com&amp;gt; wrote in message [snip]&lt;br&gt;
&lt;br&gt;
&amp;gt; hListJava = findjobj(hListbox);&lt;br&gt;
&amp;gt; hListJava = get(hListJava.Viewport,'View');&lt;br&gt;
&lt;br&gt;
&amp;gt; One problem, however, is that I do not like the way &lt;br&gt;
&amp;gt; FINDJOBJ "cycles" through all the Java objects to find the &lt;br&gt;
&amp;gt; object.  It activates and shows all the menu items, and &lt;br&gt;
&amp;gt; seems to take a long time to find the requested object. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
All you need to do is to do is to add the '-nomenu' option&lt;br&gt;
to findjobj:&lt;br&gt;
&lt;br&gt;
hListJava = findjobj(hListbox,'-nomenu');&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
