Path: news.mathworks.com!not-for-mail
From: "helper " <spamless@nospam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Listbox mousedown problems
Date: Tue, 13 May 2008 15:52:04 +0000 (UTC)
Organization: Timothy S. Farajian, Inc.
Lines: 43
Message-ID: <g0cdf4$jnj$1@fred.mathworks.com>
References: <g09d97$ir0$1@fred.mathworks.com> <g09toa$j63$1@canopus.cc.umanitoba.ca> <g0altk$221$1@fred.mathworks.com> <g0b48v$pu8$1@fred.mathworks.com> <g0b5ef$2k6$1@fred.mathworks.com> <g0bu7i$jkr$1@fred.mathworks.com> <g0c031$c1v$1@fred.mathworks.com> <g0c8fn$hmo$1@fred.mathworks.com> <g0cbqj$fj0$1@fred.mathworks.com>
Reply-To: "helper " <spamless@nospam.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210693924 20211 172.30.248.35 (13 May 2008 15:52:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 May 2008 15:52:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272923
Xref: news.mathworks.com comp.soft-sys.matlab:468182


Good idea to have the typing within the edit box update the 
listbox string rather than the callback.  This does indeed 
solve this problem.

Based on Malcom's post, prior to seeing yours, I understood 
I was using the wrong java object.  Using the correct java 
object,

hListJava = findjobj(hListbox);
hListJava = get(hListJava.Viewport,'View');

I am able to know the listbox value based on the mousedown 
event and, thus using Walter's idea, "store" the listbox 
value prior to setting the "String".

What is interesting here is that upon the mousedown event 
the Java object changes its "SelectionIndex" value and 
MATLAB fires the EditBox callback.  Within the editbox 
callback, MATLAB's "Value" property retains the original 
listbox value (until the mouseup event), while the Java 
object retains the new listbox value.  Therefore, I will 
simultaneously have acces to both and not need to "store" 
the value.

One problem, however, is that I do not like the way 
FINDJOBJ "cycles" through all the Java objects to find the 
object.  It activates and shows all the menu items, and 
seems to take a long time to find the requested object. 

Isn't there a better way for me to get a handle to this 
java object?

Regardless, I think I might implement Matt's "imtyping" 
idea since it looks cool for the user.  Also, I can do 
something similar to this method without having to resort 
to using the Java object and instead use MATLAB's 
KeyPressFcn.  Of course, I will have to accumulate all 
keypresses myself (since MATLAB's editbox doesn't update 
the "String" property until the callback), but I have done 
this successfully before.

Thanks all for your help.  You did a fine job killing my 
killer rabbit.