|
Re: Dropdown with a list widget [message #78850 is a reply to message #78819] |
Sun, 23 March 2008 08:41 |
Eclipse User |
|
|
|
Originally posted by: benjamin.wolff.web.de
hi,
a first idea on how to achieve this: you could add a focus listener on the
text widget which opens a new shell at the coords of the text widget. the
shell only contains a check table with the selectable items. the shell
closes upon loosing its focus and returns an array of the selected items.
if you need help or some examples with the codebase pls report back :).
greetings and happy easter!
-ben
|
|
|
|
Re: Dropdown with a list widget [message #79103 is a reply to message #79030] |
Mon, 24 March 2008 18:59 |
Arpit Desai Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hey Guys,
Here is a snippet of what I came up with but somehow its not working. I
am able to create and display the new shell but the List inside this new
shell is never displayed. I tried putting a simple text box too but that
didn't show up either.
What am I doing wrong here ?
Arpit
txtVersion.addFocusListener(new FocusAdapter() {
Shell sh;
Text widget;
List lst;
Composite c;
Display display;
public void focusGained(final FocusEvent event) {
widget = (Text)event.widget;
display = widget.getDisplay();
sh = new Shell(display.getCurrent().getActiveShell(), SWT.NO_TRIM);
System.out.println("x=" + widget.getLocation().x + "
y="+widget.getLocation().y);
sh.setLayout(new GridLayout());
sh.setLocation(widget.toDisplay(widget.getLocation()));
sh.setSize(widget.getSize().x, 100);
// Text t = new Text(sh, SWT.BORDER);
// t.setText("Typo");
lst = new List(sh, SWT.MULTI | SWT.V_SCROLL);
lst.setItems(new String[] { "1 - Hello", "2 - Hello", "3 - Hello",
"4 - Hello", "5 - Hello" });
lst.setVisible(true);
sh.open();
sh.redraw();
while (!sh.isDisposed()) {
if (!(display.readAndDispatch())) {
display.sleep();
}
}
}
@Override
public void focusLost(FocusEvent event) {
sh.close();
sh.dispose();
}
});
Arpit Desai wrote:
> Thanks Ben,
>
> Sounds like a good idea, I am gonna give it a shot today and will report
> back if run into any road-bumps.
>
> Thanks again
>
> Arpit
>
> Ben W. wrote:
>> hi,
>
>>
>> a first idea on how to achieve this: you could add a focus listener on
>> the text widget which opens a new shell at the coords of the text
>> widget. the shell only contains a check table with the selectable
>> items. the shell closes upon loosing its focus and returns an array of
>> the selected items. if you need help or some examples with the
>> codebase pls report back :).
>>
>> greetings and happy easter!
>> -ben
>>
|
|
|
Re: Dropdown with a list widget [message #79133 is a reply to message #79103] |
Mon, 24 March 2008 19:08 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
which RAP-Version do you use? There was a bug #204556 that seems similar
to what you are describing. That bug is solved in CVS-Head. Just in
case...
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Arpit Desai [mailto:arpitdesai23@gmail.com]
Bereitgestellt: Montag, 24. März 2008 20:00
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Dropdown with a list widget
Betreff: Re: Dropdown with a list widget
Hey Guys,
Here is a snippet of what I came up with but somehow its not working. I
am able to create and display the new shell but the List inside this new
shell is never displayed. I tried putting a simple text box too but that
didn't show up either.
What am I doing wrong here ?
Arpit
txtVersion.addFocusListener(new FocusAdapter() {
Shell sh;
Text widget;
List lst;
Composite c;
Display display;
public void focusGained(final FocusEvent event)
{
widget = (Text)event.widget;
display = widget.getDisplay();
sh = new
Shell(display.getCurrent().getActiveShell(), SWT.NO_TRIM);
System.out.println("x=" +
widget.getLocation().x + "
y="+widget.getLocation().y);
sh.setLayout(new GridLayout());
sh.setLocation(widget.toDisplay(widget.getLocation()));
sh.setSize(widget.getSize().x, 100);
// Text t = new Text(sh, SWT.BORDER);
// t.setText("Typo");
lst = new List(sh, SWT.MULTI |
SWT.V_SCROLL);
lst.setItems(new String[] { "1 - Hello",
"2 - Hello", "3 - Hello",
"4 - Hello", "5 - Hello" });
lst.setVisible(true);
sh.open();
sh.redraw();
while (!sh.isDisposed()) {
if
(!(display.readAndDispatch())) {
display.sleep();
}
}
}
@Override
public void focusLost(FocusEvent event) {
sh.close();
sh.dispose();
}
});
Arpit Desai wrote:
> Thanks Ben,
>
> Sounds like a good idea, I am gonna give it a shot today and will
> report back if run into any road-bumps.
>
> Thanks again
>
> Arpit
>
> Ben W. wrote:
>> hi,
>
>>
>> a first idea on how to achieve this: you could add a focus listener
>> on the text widget which opens a new shell at the coords of the text
>> widget. the shell only contains a check table with the selectable
>> items. the shell closes upon loosing its focus and returns an array
>> of the selected items. if you need help or some examples with the
>> codebase pls report back :).
>>
>> greetings and happy easter!
>> -ben
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03040 seconds