Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextField problem in Mac, it keeps selecting the text



Thanks Mike,
Amazing, I spent hours trying to figure out this bug and now realize that it is done intentionally. For my application it is critical that the cursor stays where it was last time it had the focus! What is the workaround?


I can understand that Mac behaves in certain ways but I do not believe that the portability of Java should have been scarified! We Java programmers expect JVM to behave exactly the same in different operating systems. If you pick and choose, you will confuse us and discourage us from porting our application to Mac because of the extra coding involved. As insignificant as this issue may seem it rendered my entire product useless with tons of complains from my Mac users.

Regards,
Saeid


Mike Swingler wrote:
On Jun 30, 2008, at 8:31 PM, email@hidden wrote:

There is an amazingly stupid problem with swing TextField in Mac version
of JVM.

If you try a simple jTextField.setText("Hello") method in Java it works
fine in windows, but in Mac OS it selects/highlights the entire text.
Even if I use:
jTextField.setSelectionStart(0)
jTextField.setSelectionEnd(0)

it continues to select the entire text. However if I put:

jTextField.setSelectionStart(1)
jTextField.setSelectionEnd(2)

it behaves correctly but only selecting the 2nd character. Why is this?!

This was done to match the native "select all on focus" behavior present in Mac OS X text widgets. If you move focus between textfields on Mac OS X, you will find that they always select their contents when gaining focus. In Java, we also attempt to preserve the text field selection and the caret location if it has been customized by the user. As pointed out by another developer here, this has been documented in the release notes for Java on Mac OS X 10.5 Leopard: http://developer.apple.com/releasenotes/Java/JavaLeopardRN/ResolvedIssues/chapter_3_section_5.html#4890361



Cheers, Mike Swingler Java Runtime Engineer Apple Inc.


--
<p>Regards, <br>
<br>
Saeid <br>
<a href="http://www.runiter.com";>www.runiter.com</a> </p>
<p><br>
<br>
We trust 1&amp;1 Internet. Inc. for all our hosting and e-mail needs. Visit
<a href="http://www.1and1.com/?k_id=16207070";>http://www.1and1.com/?k_id=16207070</a> to see why!</p>


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.