Focus problem on Mac [message #444671] |
Wed, 20 October 2004 09:46 |
xxx Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Sorry I forgot to add the example code in my previous post :
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class TestFocusLost {
private static Display display;
private static Shell shell;
public static void main(String[] args) {
display = new Display ();
shell = new Shell (display);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
shell.setLayout(gridLayout);
Text text = new Text(shell, SWT.BORDER);
text.setText("text 1");
text.setLayoutData(new GridData());
text.addFocusListener(new TestFocusListener(text));
Text text2 = new Text(shell, SWT.BORDER);
text2.setText("text 2");
text2.setLayoutData(new GridData());
Button button = new Button(shell, SWT.PUSH);
button.setText("Click here");
button.setLayoutData(new GridData());
shell.pack();
shell.open();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
display.dispose ();
}
}
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Text;
public class TestFocusListener implements FocusListener {
private Text text;
public TestFocusListener(Text text) {
this.text = text;
}
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
System.out.println("focusLost " + this.text.getText());
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.01811 seconds