|
|
Re: Set focus problem in editor [message #513614 is a reply to message #513228] |
Wed, 10 February 2010 12:14 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Did you disable textBox1? This should not just be happening for free.
Setting enablement and focus while the error dialog is up should not be a
problem, the snippet below does it. Does the snippet work for you? And,
which platform and swt version are you using?
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Text text1 = new Text(shell, SWT.SINGLE);
final Text text2 = new Text(shell, SWT.SINGLE);
shell.pack();
shell.open();
text2.setFocus();
text1.setEnabled(false);
display.timerExec(2222, new Runnable() {
public void run() {
final Shell child = new Shell(shell);
child.setLayout(new FillLayout());
Button button = new Button(child, SWT.PUSH);
button.setText("Push");
button.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
text1.setEnabled(true);
text1.setFocus();
child.dispose();
}
});
child.pack();
child.open();
while (!child.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"jay" <jaydeep.marumale@gmail.com> wrote in message
news:hkrlm2$rhb$1@build.eclipse.org...
> I have an editor which has 3 text boxes: textBox1, textBox2, textBox3.
> I enter certain values in text box2 and then in textBox3 and keep textBox1
> empty,then on saving the editor, an error message is shown that "textBox1
> cannot be empty".
> On clicking the OK button of the error message dialog box, the focus is
set
> to textBox3 which was last edited.
> I want the focus to be set on the textBox1, ie. the textbox which shows
the
> error.
> For this I tried using the setFocus() method but I found that the
> isEnabled() property of textBox1 is returning false and thats why the
focus
> is not setting on the textBox1.
> I also tried textBox1.setEnabled(true), but this is also not working.
> Before save the state of the editor is saved in the Display and after the
> save is complete the focus is returned back to the widget last edited.
>
> Can you suggest something?
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.90777 seconds