Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Combo.setSelection(Point p) doesn't work on GTK Linux?
Combo.setSelection(Point p) doesn't work on GTK Linux? [message #445484] |
Sun, 07 November 2004 03:04 |
Eclipse User |
|
|
|
Originally posted by: ukalumni.hotmail.com
I've got the following code running on Linux GTK. However, there is
never any selection. Is this not supported on my platform, or am I
missing something?
combo.select(index);
combo.setText(combo.getItem(index));
combo.setSelection(new Point(2, 3));
combo.setFocus();
Thanks,
--Michael
|
|
|
Re: Combo.setSelection(Point p) doesn't work on GTK Linux? [message #445705 is a reply to message #445484] |
Tue, 09 November 2004 20:30 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Michael,
Setting the focus to the combo is resetting the selection to the full text.
If you swap your setSelection and setFocus lines then this should work for
you. I used the following snippet:
public static void main(String[] args) {
Display display = new Display ();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
final Combo combo = new Combo(shell, SWT.NONE);
combo.setBounds(10,10,60,30);
combo.setItems(new String[] {"item 1","item 2","item 3"});
shell.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
int index = 1;
combo.select(index);
combo.setText(combo.getItem(index));
combo.setFocus();
combo.setSelection(new Point(2, 3));
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"Michael Molloy" <ukalumni@hotmail.com> wrote in message
news:cmk5n7$qra$1@eclipse.org...
> I've got the following code running on Linux GTK. However, there is
> never any selection. Is this not supported on my platform, or am I
> missing something?
>
> combo.select(index);
> combo.setText(combo.getItem(index));
> combo.setSelection(new Point(2, 3));
> combo.setFocus();
>
>
> Thanks,
> --Michael
|
|
| |
Re: Combo.setSelection(Point p) doesn't work on GTK Linux? [message #446143 is a reply to message #445705] |
Wed, 17 November 2004 19:48 |
Eclipse User |
|
|
|
Originally posted by: ukalumni.hotmail.com
Thank you Grant. Sorry I missed this for a week.
--Michael
Grant Gayed wrote:
> Michael,
>
> Setting the focus to the combo is resetting the selection to the full text.
> If you swap your setSelection and setFocus lines then this should work for
> you. I used the following snippet:
>
> public static void main(String[] args) {
> Display display = new Display ();
> Shell shell = new Shell(display);
> shell.setBounds(10,10,200,200);
> final Combo combo = new Combo(shell, SWT.NONE);
> combo.setBounds(10,10,60,30);
> combo.setItems(new String[] {"item 1","item 2","item 3"});
> shell.addListener(SWT.MouseDown, new Listener() {
> public void handleEvent(Event event) {
> int index = 1;
> combo.select(index);
> combo.setText(combo.getItem(index));
> combo.setFocus();
> combo.setSelection(new Point(2, 3));
> }
> });
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
> }
>
> Grant
>
> "Michael Molloy" <ukalumni@hotmail.com> wrote in message
> news:cmk5n7$qra$1@eclipse.org...
>
>>I've got the following code running on Linux GTK. However, there is
>>never any selection. Is this not supported on my platform, or am I
>>missing something?
>>
>>combo.select(index);
>>combo.setText(combo.getItem(index));
>>combo.setSelection(new Point(2, 3));
>>combo.setFocus();
>>
>>
>>Thanks,
>>--Michael
>
>
>
|
|
|
Goto Forum:
Current Time: Mon Jun 17 06:26:20 GMT 2024
Powered by FUDForum. Page generated in 0.03983 seconds
|