Request for review: 7124528 [macosx] Selection is not cleared properly in text component.

Sergey Bylokhov sergey.bylokhov at oracle.com
Thu Feb 9 07:08:49 PST 2012


08.02.2012 22:51, Mike Swingler wrote:
> On Feb 8, 2012, at 9:14 AM, Sergey Bylokhov wrote:
>
>> 08.02.2012 20:16, Mike Swingler пишет:
>>> On Feb 8, 2012, at 8:04 AM, Sergey Bylokhov wrote:
>>>
>>>> 08.02.2012 20:03, Mike Swingler wrote:
>>>>> On Feb 8, 2012, at 2:05 AM, Sergey Bylokhov wrote:
>>>>>
>>>>>> Hi Everyone,
>>>>>> Now we reset selection in text components on focuslost event.
>>>>>>
>>>>>> Bug: http://monaco.sfbay.sun.com/detail.jsf?cr=7124528
>>>>>> Webrev can be found at: http://cr.openjdk.java.net/~serb/7124528/webrev.00/
>>>>> That bug isn't publicly accessible. Could you give us the gist of it?
>>>> jira:
>>>> http://java.net/jira/browse/MACOSX_PORT-616
>>> Thanks. After this fix, does the text field completely select it's contents when it is re-focused by tabbing into it?
>> Under aqua l&f text components reselect text if cursor was at first or at last position.
>> AquaCaret.java
>> public void focusGained(final FocusEvent e) {
>> ....
>> final int dot = getDot();
>> final int mark = getMark();
>> if (dot == mark) {
>> if (dot == 0) {
>> component.setCaretPosition(end);
>> component.moveCaretPosition(0);
>> } else if (dot == end) {
>> component.setCaretPosition(0);
>> component.moveCaretPosition(end);
>> }
>> }
> This was a compromise to pass the TCK for Swing components, and does not reflect the ideal state.
>
> Native AppKit single-line text fields (and the Java SE 6 AWT text fields) always select the content completely when you tab back into them, regardless of the last selection or cursor location. If you are already planning to change the selection state, just select-all.
Looks like I found workaround. in jdk 6 when the textfield loses focus, 
the caret position will be set to 0. If we reset it too, text will be 
reselected automatically.
New version:
http://cr.openjdk.java.net/~serb/7124528/webrev.01/
>
> Just try out the behavior in a new compose message window in Mail.app.
>
> Regards,
> Mike Swingler
> Apple Inc.
>


-- 
Best regards, Sergey.



More information about the macosx-port-dev mailing list