Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Initial focus in dialog
Initial focus in dialog [message #437421] Fri, 04 June 2004 07:26 Go to next message
Eclipse UserFriend
Originally posted by: john.rmts.donpac.ru

Hello,

I have simple dialog. How can I set focus to text box on dialog opening?
text.setFocus() is not working.

public class MyDialog extends TitleAreaDialog {

public MyDialog(Shell parentShell) {
super(parentShell);
}
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new GridLayout());
container.setLayoutData(new GridData(GridData.FILL_BOTH));

final CTabFolder tabFolder = new CTabFolder(container, SWT.BORDER);
tabFolder.setLayout(new GridLayout());
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));

final CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
tabItem.setText("MyTab");

final Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayout(new GridLayout());
tabItem.setControl(composite);

Text text = new Text(composite, SWT.BORDER);
text.setFocus();

return area;
}
}


My Eclipse Platform Version: 2.1.3 Build id: 200403101828
Re: Initial focus in dialog [message #437549 is a reply to message #437421] Mon, 07 June 2004 14:33 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
I suspect TitleAreaDialog (whatever that is) is burning you, assigning the
focus away after you have already set it. What you are doing should work in
a stand alone example. Please enter a bugzilla report if it does not.
Thanks.

"Eugene Prokopiev" <john@rmts.donpac.ru> wrote in message
news:c9p7gv$e7p$1@eclipse.org...
> Hello,
>
> I have simple dialog. How can I set focus to text box on dialog opening?
> text.setFocus() is not working.
>
> public class MyDialog extends TitleAreaDialog {
>
> public MyDialog(Shell parentShell) {
> super(parentShell);
> }
> protected Control createDialogArea(Composite parent) {
> Composite area = (Composite) super.createDialogArea(parent);
> Composite container = new Composite(area, SWT.NONE);
> container.setLayout(new GridLayout());
> container.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> final CTabFolder tabFolder = new CTabFolder(container, SWT.BORDER);
> tabFolder.setLayout(new GridLayout());
> tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> final CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
> tabItem.setText("MyTab");
>
> final Composite composite = new Composite(tabFolder, SWT.NONE);
> composite.setLayout(new GridLayout());
> tabItem.setControl(composite);
>
> Text text = new Text(composite, SWT.BORDER);
> text.setFocus();
>
> return area;
> }
> }
>
>
> My Eclipse Platform Version: 2.1.3 Build id: 200403101828
>
Previous Topic:Accessibility for MenuItem, TreeItem
Next Topic:How to setBackground() to a push button
Goto Forum:
  


Current Time: Fri Apr 19 07:12:07 GMT 2024

Powered by FUDForum. Page generated in 0.02789 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top