Project: Eclipse_Platform_UI
Bug 390924 Pressing enter calls the @Focus Method
Reported: 2012-10-02 08:27:04 | Status: verified fixed

I think we have a regression in Eclipse 4.2.1. If I define a user interface and press [ENTER] in a text field the @Focus method is called. Example: Create the following part and press enter in one of the Text fields, e.g. the one defined with SWT.MULTI Let me know if you need a complete example, I can upload one. -------------- package com.example.e4.rcp.ui.parts; import javax.annotation.PostConstruct; import org.eclipse.e4.ui.di.Focus; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.DateTime; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; public class TodoDetailsPart { private Text text; private Text text_1; private Text text_2; private DateTime dateTime; private Button btnClickMe; private Label lblNewLabel_2; @PostConstruct public void buildUi(Composite parent) { parent.setLayout(new GridLayout(2, false)); Label lblSummary = new Label(parent, SWT.NONE); lblSummary.setText("Summary"); text = new Text(parent, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(parent, SWT.NONE); lblNewLabel_2 = new Label(parent, SWT.NONE); lblNewLabel_2.setText("New Label"); Label lblNewLabel = new Label(parent, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText("Description"); text_1 = new Text(parent, SWT.BORDER| SWT.MULTI); GridData gd_text_1 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_text_1.heightHint = 92; text_1.setLayoutData(gd_text_1); Label lblNewLabel_1 = new Label(parent, SWT.NONE); lblNewLabel_1.setText("Stuff"); text_2 = new Text(parent, SWT.BORDER); text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(parent, SWT.NONE); dateTime = new DateTime(parent, SWT.BORDER); btnClickMe = new Button(parent, SWT.CHECK); btnClickMe.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { } }); btnClickMe.setText("Click me"); new Label(parent, SWT.NONE); } @Focus public void focus() { btnClickMe.setFocus(); } }

Files changed in fix:
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java