|
Jesse Lai <"jlai.[DELETETHIS]matlab"@gmail[NOSPAM].moc>
wrote in message
<vYadnZaxFL2X-4zVnZ2dnUVZ_s2tnZ2d@comcast.com>...
> Walter Roberson wrote:
> > In article <oLCdnV7AEt4bapLVnZ2dnUVZ_oOnnZ2d@comcast.com>,
> > Jesse Lai <"jlai.[DELETETHIS]matlab"@gmail[NOSPAM].moc>
wrote:
> >> Is there a way to detect the position of the cursor in
an edit box in a
> >> GUI? I have a couple of different use cases where this
would be useful.
> >
> > Only by going in at the Java level.
>
> I thought that might be the case. I believe that I have
found the way
> using Java as Walter suggested. If you have the handle to
the edit box
> (e.g. hEdit), then I used Yair Altman's findjobj to get
the java handle as
>
> jEdit = findjobj(hEdit);
>
> Then you can use:
>
> get(jEdit, 'SelectionStart')
> get(jEdit, 'SelectionEnd')
>
> or the equivalent set methods.
>
> Is there a better way to get the java handle directly
without using this
> other function?
>
> Thanks,
>
> Jesse
Hi Jesse,
It sounds like I am attempting a similar task in my MATLAB
GUI. I have an edit uicontrol where I allow the user in
type in a password. I handle each key press with the edit
uicontrol's 'KeyPressFcn'. As characters are typed in, I
replace the characters with asterisks and set the string of
asterisks to the edit uicontrol. If a backspace is pressed,
I delete the last character of the string. BUT, what if the
user uses the mouse to highlight all or some of the string,
then hits backspace? They will expect the entire
highlighted portion of the string to be deleted, right?
So grabbing the Java object and checking the
'SelectionStart' and 'SelectionEnd' properties definitely
seems like a potential solution. But these properties do
not seem to be properly set. 'SelectionStart' and
'SelectionEnd' always return equivalent values. Have you
encountered this?
Thanks,
Michelle Kline
|