Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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 #445753 is a reply to message #445484] Wed, 10 November 2004 15:18 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Michael,

Switching your last two lines should make this work on gtk. The setFocus()
is resetting your previously-set selection.

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 Go to previous message
Eclipse UserFriend
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
>
>
>
Previous Topic:SWT and Swing controls on SWT Composite
Next Topic:Graphic Library
Goto Forum:
  


Current Time: Sat Oct 24 09:00:38 GMT 2020

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

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

Back to the top