Question about Customizing Combox [message #452552] |
Tue, 22 March 2005 08:24 |
Eclipse User |
|
|
|
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 |
Stefano Zaccaria 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 |
Grant Gayed 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 |
Eclipse User |
|
|
|
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.
>>
>>
>>
>>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03364 seconds