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

Bug 16329

Summary: [EditorMgmt] Activate editor (F12) does not set focus in editor
Product: [Eclipse Project] Platform Reporter: Luca Davanzo <luca.davanzo>
Component: UIAssignee: Douglas Pollock <douglas.pollock>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, n.a.edgar
Version: 2.0Keywords: accessibility
Target Milestone: 3.1   
Hardware: All   
OS: All   
Whiteboard:

Description Luca Davanzo CLA 2002-05-17 19:32:24 EDT
activate editor shortcut (f12) not always work: for example, moving with 
ctrl+tab from the java editor to the toolbars and then pressing f2 doesnt 
activate the editor
Comment 1 Nick Edgar CLA 2002-05-18 22:41:12 EDT
There is a known problem in whereby accelerators aren't processed when a 
toolbar button has focus.  I could not find the PR though.
Comment 2 Mike Wilson CLA 2002-05-19 11:41:55 EDT
SN may not be around next week. If not, FH can you take a look at this and 
see if there is anything we can do? I thought the "accelerators not 
processed when toolbar button has focus" issue had been resolved.

Comment 3 Steve Northover CLA 2002-06-27 20:44:01 EDT
I believe this has been fixed for a while.  The following code implements an 
F12 accelerator and sets focus to a toolbar.  When F12 is pressed, the 
accelerator is fired:

public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell (display);
	Menu bar = new Menu (shell, SWT.BAR);
	shell.setMenuBar (bar);
	MenuItem fileItem = new MenuItem (bar, SWT.CASCADE);
	fileItem.setText ("&File");
	Menu fileMenu = new Menu (shell, SWT.DROP_DOWN);
	MenuItem newItem = new MenuItem (fileMenu, SWT.PUSH);
	newItem.setText ("&New\tF12");
	newItem.setAccelerator (SWT.F12);
	fileItem.setMenu (fileMenu);
	Listener listener = new Listener () {
		public void handleEvent (Event e) {
			System.out.println ("Got it! - " + e.widget);
		}
	};
	newItem.addListener (SWT.Selection, listener);
	ToolBar toolBar = new ToolBar (shell, SWT.BORDER | SWT.FLAT);
	for (int i=0; i<12; i++) {
		int style = (i % 3 == 0) ? SWT.CHECK : SWT.PUSH;
		ToolItem item = new ToolItem (toolBar, style);
		item.setText ("Item &" + i);
		item.addListener (SWT.Selection, listener);
	}
	toolBar.pack ();
	Button button = new Button (shell, SWT.PUSH);
	button.setText ("&Button");
	button.setBounds (64, 64, 64, 64);
	button.addListener (SWT.Selection, listener);
	shell.pack ();
	shell.open ();
	toolBar.setFocus ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
Comment 4 Nick Edgar CLA 2002-07-03 14:18:39 EDT
Can still reproduce it in 2.0.
Comment 5 Nick Edgar CLA 2002-07-03 14:19:23 EDT
Works OK if toolbar gets focus from a view.
Looks like when the editor is already active, it does not bother to set focus 
back to the editor.
Comment 6 Douglas Pollock CLA 2004-07-13 16:58:16 EDT
Fixed in CVS.  After the editor is activated, focus is then set in the editor 
part. 
 
Updated the summary and keywords to (try to) more clearly reflect the problem. 
Comment 7 Douglas Pollock CLA 2005-05-31 10:53:00 EDT
Verified in 3.1 RC1.