[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: Hiding a Combo Box

This looks like it may be a bug in the Windows SWT implementation of Combo.
I believe the following code shows the error if the button (the "other control") is given focus before the shell is opened.
The suggested work-around is to set focus to the other control *after* the shell has been opened.
I will open a PR to investigate further.
 
Carolyn
 
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class ComboNoFocusTest {
    public static void main(String[] args) {
        Display display =
new Display();
        Shell shell =
new Shell(display);
        shell.setLayout(
new RowLayout());
        shell.setText(
"Combo No Focus Test");

        String items[] = {
"one", "two", "three"};
        Combo combo =
new Combo(shell, SWT.SINGLE | SWT.BORDER);
        combo.setItems(items);
        combo.setText(items[0]);

        Button button = new Button(shell, SWT.PUSH);
        button.setText(
"Button");
        //button.setFocus();  // setting focus here shows bug

        shell.pack();
        shell.open();
        //button.setFocus();  // setting focus here works ok

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) display.sleep();
        }
    }
}
 
"David Insel" <deinsel@xxxxxxxxxx> wrote in message news:9kpept$okr$1@xxxxxxxxxxxxx...
> I am trying to make a new Combo by using
> "new Combo(containerGroup,SWT.SINGLE|SWT.BORDER)" but the problem is I do
> not want this combo box highlighted after it is created ( I am already
> changing the focus to another control on the canvas).  The only way that I
> have figured out how to do this is to use the style bit SWT.READ_ONLY but
> I do not want my combo box to be read only.  I have to set the item and
> then myComboBox.select(0); (So I can have a default String displayed).
> Will Combo ever support the style bit noFocus?
>
> Can anyone help me out or recommend a work around?
>
> Please E-mail me... 
>
> -Dave
>