Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 28842

Summary: Need a way to turn on/off the focus ring
Product: [Eclipse Project] Platform Reporter: Andre Weinand <andre_weinand>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: boris, bpasero, bugzilla, channingwalton, cmlenz, grant_gayed, kai-uwe_maetzel, michaelvanmeekeren, Mike_Wilson, paulslau
Version: 2.1   
Target Milestone: 3.3 M6   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on:    
Bug Blocks: 52030, 56476, 170259    
Attachments:
Description Flags
Double Focus ring problem
none
Focus Ring runs through compare viewer selection
none
No border around preferences tree none

Description Andre Weinand CLA 2002-12-23 11:12:33 EST
M4
Swt needs a way to turn on/off the focus ring for controls.
Mac applications use the focus ring only for dialogs, not for top-level windows.
A prominent example is the Mac Finder which uses different selection colors to show 
which column has the keyboard focus (in multi column mode).
More important for Eclipse is that some viewers/editors are constructed from several SWT 
controls and need a way to control themselves whether to show the focus for an 
individual control or for its enclosing composite. An example for this is the compare 
viewer which aligns canvases and StyledTexts side by side.
Comment 1 Felipe Heidrich CLA 2003-01-10 16:38:06 EST
reassign to SN
Comment 2 Andre Weinand CLA 2003-01-30 15:41:40 EST
One idea of getting rid of the focus ring without requiring new API would be to display the 
focus ring only in modal dialogs.
Comment 3 Steve Northover CLA 2003-01-30 17:06:28 EST
Other than the Mac Finder, can you show fnid another example or the doc that 
describes this.  For example, the project builder shows a focus ring (the 
wrong color) and it's not a dialog.

Is the problem that the compare viewer looks ugly?
Comment 4 Andre Weinand CLA 2003-01-31 04:09:49 EST
Apple Tools:
The Project Builder shows the focus ring in the tree only. Never in any text editors. 
FileMerge doesn't do it in main windows, but in dialogs.
JavaBrowser has a focus ring for the class pane, but not for text.
Apple Mail uses a focus rings only in the search field of the main window, but not for the 
table and text views.
Apple's Script Editor uses focus ring only in toolbar Search field and in Open Dictionary 
dialog but not around text area in main window.
Property List Editor uses focus ring for Table's Cell Editor (!) but not for  the Table view 
itself. BTW: Our cell editors don't support this!?
Addressbook: no focus border
iCal: focus border only for search field in main window
iTunes, iPhoto: focus border only for search field in main window, browser uses different 
selection color for focus/unfocus panes (like Finder)

Non-Apple Tools:
MetroWerks CodeWarrior doesn't have a focus ring in top-level windows but uses a filled 
/hollow selection.
RealBasic IDE doesn't have focus rings at all.

Bottom Line:
I've found no application that uses a focus ring the same we do.
In most cases focus ring is used:
- in dialogs
- in toolbar text fields (search)
- in overlay cell editors
It is never used for the main text editor area.

Yes, the focus ring makes compare viewer ugly. However, it makes all text editors noisy 
because you get another blue line next to our vertical ruler/scrollbar/overview rulers.

(Performance consideration (without measuring it :-) : how expensive is the focus ring? 
Do we invalidate the ring only, or do we invalidate the rectangular area inside the ring 
too?) 

Comment 5 Steve Northover CLA 2003-02-06 11:07:27 EST
We probably won't get to this but we did fix a performance problem associated 
with it.
Comment 6 Veronika Irvine CLA 2003-03-11 11:19:50 EST
*** Bug 34627 has been marked as a duplicate of this bug. ***
Comment 7 Andre Weinand CLA 2004-02-24 10:54:07 EST
Since the Mac's focus ring seem to make more troubles in the new look,
I think we should find a way to make it optional.

4 options:

- new SWT flag: SWT.FOCUS_RING
   problem: applications developed on non-Mac platforms will forget to use this flag
            -> there will be no focus ring at all.

- new SWT flag: SWT.NO_FOCUS_RING
     problem: applications developed on non-Mac platforms will forget to use this flag
            -> double focus ring won't go away.

- automatic 1: hide focus ring for controls in "normal" windows; show it in dialog" windows
     problem: too clever...

- automatic 2: Text shows focus ring by default; StyledText (and all other controls) hide
                    focus ring by default (and we can provide a flag SWT.FOCUS_RING for turning it on);
                    
     problem: none obvious :-)
                    A few tables and trees in dialogs will loose their focus ring.
                    Not a big deal since Apple itself does not use the focus ring consequently.


Steve, do you think option 3 makes sense and is feasable?
Comment 8 Andre Weinand CLA 2004-02-24 10:55:29 EST
[oops, I meant option 4 (automatic 2)]
Comment 9 Christopher Lenz CLA 2004-02-24 11:36:26 EST
I have no idea of this is of any help because I don't know much about SWT's inner workings, but here's 
my expectation of when the focus ring should appear and when it shouldn't:

If I can take focus away from the control that currently has keyboard focus using the tab key, then it 
should display the focus ring. On the other hand, if pressing tab has no effect, or does not move 
keyboard focus to the next control, no focus ring should be displayed.

Based on this definition, neither the text editor area nor the view part content areas should have a focus 
ring, because I can't "tab out" of them.
Comment 10 Andre Weinand CLA 2004-03-20 11:28:33 EST
*** Bug 55452 has been marked as a duplicate of this bug. ***
Comment 11 Grant Gayed CLA 2004-04-01 12:08:53 EST
SN this has been identified as an important OS X item, so I've updated its 
priority.  Can you revisit it before M9?
Comment 12 Andre Weinand CLA 2004-04-13 07:42:04 EDT
Created attachment 9426 [details]
Double Focus ring problem

Nicely shows the double focus ring problem with the new look.
Comment 13 Steve Northover CLA 2004-05-05 11:13:56 EDT
Downgraded ... sorry about that but Eclipse doesn't think this is "stop ship".
Comment 14 Steve Northover CLA 2004-05-26 10:07:19 EDT
PMC have indicated that this is stop ship (wow).  Upgrading to P1.
Comment 15 Silenio Quarti CLA 2004-05-26 18:34:55 EDT
As a temporary fix, you can define the system property "org.eclipse.swt.internal.carbon.noFocusRing".

If this system property is defined when the display is created and the control is not in a dialog, the 
Tree/Table/List/Composite/Text controls will not have the focus ring.

Fixed in HEAD.
Comment 16 Silenio Quarti CLA 2004-05-28 15:02:29 EDT
Andre,

Without the focus ring, in-place editing in the Navigator looks bad since there is no border around the 
text field. I guess there is Mac specific code somewhere that removes the one pixel black border.
Comment 17 Andre Weinand CLA 2004-06-02 04:48:37 EDT
I've added a check for the system property.
See bug #38412
Comment 18 Silenio Quarti CLA 2004-06-07 11:56:59 EDT
Lowering priority since there is a temporary fix in place. This will be 
addressed again after R3.0 ships.
Comment 19 Andre Weinand CLA 2004-11-02 05:18:36 EST
Can we try to address this issue for 3.1?
Right now almost everything works OK with the exception of Compare views in dialogs.
In dialogs the focus ring isn't turned off, so we still see the odd behavior shown in the second attached 
screenshot. 
Comment 20 Andre Weinand CLA 2004-11-02 05:20:48 EST
Created attachment 15555 [details]
Focus Ring runs through compare viewer selection
Comment 21 Benjamin Pasero CLA 2005-02-21 12:45:13 EST
I would like to remove the focusring from dialogs too. Why not have a
"SWT.NO_FOCUS_RING" style hint? Peoples forgetting about it, will get the same
result as now, and those that find it annoying will use it in their applications.

Ben
Comment 22 Paul Slauenwhite CLA 2006-10-25 12:21:26 EDT
Can you provide an update on this defect?
Comment 23 Paul Slauenwhite CLA 2006-10-25 12:36:10 EDT
Please increase the severity to major and priority to P1 since it is required to resolve a blocking TPTP defect (https://bugs.eclipse.org/bugs/show_bug.cgi?id=126575) and has been on the books for nearly 4 years.
Comment 24 Mike Wilson CLA 2006-10-25 13:17:37 EDT
I increased the severity, since this reflects your point of view about the important of the problem. It's clearly not P1 from the SDK's point of view.

Note to SWT: 126575 can be unblocked by just declaring the existence of that property as part of the SWT API.
Comment 25 Silenio Quarti CLA 2007-02-21 17:32:02 EST
We have decided to use the SWT.BORDER style to determine if the focus ring should appear. Mac trees and tables tie the focus ring and border together, you can either have both of them or none.

Tree/tables/editors in the eclipse views (Package Explorer, etc) do not specify the SWT.BORDER style, so they won't have double borders (comment#12). The tables in the MANIFEST.MF forms (bug#173572) will have borders as expected. 

The org.eclipse.swt.internal.carbon.noFocusRing property is no longer used in SWT.
Comment 26 Mike Wilson CLA 2007-03-17 10:07:37 EDT
Created attachment 61191 [details]
No border around preferences tree

I expected to see a focus ring around the tree in the preferences dialog, but did not get one. Am I just confused, or is this a problem?
Comment 27 Silenio Quarti CLA 2007-03-19 11:01:09 EDT
That is working as expected. If the SWT.BORDER bit is removed, both the border and the focus ring will not show.