Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Question about Customizing Combox
Question about Customizing Combox [message #452552] Tue, 22 March 2005 08:24 Go to next message
Eclipse UserFriend
Originally posted by: chauntowpin.yahoo.com.cn

Hi all,
I want a Combox, when the Combox get the focus, it can automatically pop
up the drop-down-windown to show the list , User then can select one option
out of them. During the process there is no need for user to click using
mouse. This feature are welcomed by some users who want to fill forms only
with keyborad.
I know in Delphi, it is very simple to do this. But how in SWT. Can some
one lend me a hand, thanks.
Re: Question about Customizing Combox [message #452557 is a reply to message #452552] Tue, 22 March 2005 11:32 Go to previous messageGo to next message
Stefano Zaccaria is currently offline Stefano ZaccariaFriend
Messages: 48
Registered: July 2009
Member
There is another topic about this issue in this newsgroup called "Combo box
popup" post by Mikko but this not solve the
problem that you have. So do I have this problem and I try with this code
that i find in this news-group. ( topic called "3 problems creatinf an
auto-complete combo controll" by Jim ). There is a good solution, but there
is not the solution that I search but if it help you...

Stefano

public class AutoSelectCombo {
private Combo combo;
private boolean programmaticallyChanging;

public AutoSelectCombo(Composite composite, ArrayList list) {
combo = new Combo(composite, SWT.DROP_DOWN);
programmaticallyChanging = false;

for (int i = 0; i < list.size(); ++i) {
combo.add((String) list.get(i));
}

addModifyListener(
new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (!programmaticallyChanging) {

int index = indexOfClosestMatch(getText());
int length = getText().length();
System.out.println(index);
switch (index) {
case -1:
programmaticallyChanging = true;
setText("");
programmaticallyChanging = false;
break;
default:
select(index);
programmaticallyChanging = true;
setText(getItem(index));
setSelection(new Point(length,
getText().length()));
programmaticallyChanging = false;
break;
}
}
}
}
);
}

public int indexOfClosestMatch (String text) {
System.out.println(text);
int index = -1;
String[] items = combo.getItems();
for (int i = 0; i < items.length; ++i) {
if (items[i].startsWith(text)) {
index = i;
break;
}
}
return index;
}
...
}






"chauntowpin" <chauntowpin@yahoo.com.cn> ha scritto nel messaggio
news:d1opgc$sgv$1@news.eclipse.org...
> Hi all,
> I want a Combox, when the Combox get the focus, it can automatically pop
> up the drop-down-windown to show the list , User then can select one
> option out of them. During the process there is no need for user to click
> using
> mouse. This feature are welcomed by some users who want to fill forms
> only with keyborad.
> I know in Delphi, it is very simple to do this. But how in SWT. Can some
> one lend me a hand, thanks.
>
>
>
>
Re: Question about Customizing Combox [message #452564 is a reply to message #452552] Tue, 22 March 2005 13:36 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
There is no api for programmatically showing a Combo's items, though there
is a request for this, see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=21619 .

An alternative is to create the Combo with SWT.SIMPLE. This will leave the
Combo in an expanded state at all times, which may be reasonable in your
context.

Grant

"chauntowpin" <chauntowpin@yahoo.com.cn> wrote in message
news:d1opgc$sgv$1@news.eclipse.org...
> Hi all,
> I want a Combox, when the Combox get the focus, it can automatically
pop
> up the drop-down-windown to show the list , User then can select one
option
> out of them. During the process there is no need for user to click using
> mouse. This feature are welcomed by some users who want to fill forms
only
> with keyborad.
> I know in Delphi, it is very simple to do this. But how in SWT. Can
some
> one lend me a hand, thanks.
>
>
>
>
Re: Question about Customizing Combox [message #452568 is a reply to message #452564] Tue, 22 March 2005 14:19 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

I suppose you could dispose the "closed" combo when it gets focus,
replace it with SWT.SIMPLE combo, call layout() and force the focus back
to the new combo. (And vice versa when lose focus.) Don't know how
horrible that would look.

Bob

Grant Gayed wrote:
> There is no api for programmatically showing a Combo's items, though there
> is a request for this, see
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=21619 .
>
> An alternative is to create the Combo with SWT.SIMPLE. This will leave the
> Combo in an expanded state at all times, which may be reasonable in your
> context.
>
> Grant
>
> "chauntowpin" <chauntowpin@yahoo.com.cn> wrote in message
> news:d1opgc$sgv$1@news.eclipse.org...
>
>>Hi all,
>> I want a Combox, when the Combox get the focus, it can automatically
>
> pop
>
>>up the drop-down-windown to show the list , User then can select one
>
> option
>
>>out of them. During the process there is no need for user to click using
>>mouse. This feature are welcomed by some users who want to fill forms
>
> only
>
>>with keyborad.
>> I know in Delphi, it is very simple to do this. But how in SWT. Can
>
> some
>
>>one lend me a hand, thanks.
>>
>>
>>
>>
>
>
>
Previous Topic:Need to know when the checkbox is clicked
Next Topic:SWT/Swing mixed causes invalid thread access
Goto Forum:
  


Current Time: Tue Apr 16 05:32:41 GMT 2024

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

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

Back to the top