|
|
|
Re: Hook combo box dropdown event [message #452911 is a reply to message #452838] |
Mon, 28 March 2005 14:27 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
That's strange, the following snippet works for me with the latest swt and
gtk-2.2.4. If the following doesn't work for you and if you're using the
latest swt with gtk > 2.2.4 then please log a bug report with Platform -
SWT, thanks.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
Button button = new Button(shell, SWT.PUSH);
button.setBounds(10,10,10,10);
final Combo combo = new Combo(shell, SWT.NONE);
combo.setBounds(50,50,100,30);
combo.addListener(SWT.FocusIn, new Listener() {
public void handleEvent(Event event) {
if (combo.getItemCount() > 0) return;
for (int i = 0; i < 5; i++) {
combo.add("item " + i);
}
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"John Krasnay" <john@krasnay.ca> wrote in message
news:63e05c129f4ca72e1e1abb52b3e82e7b$1@www.eclipse.org...
> > There isn't a way to hook a drop-down listener to a Combo. Surprisingly
I
> > couldn't find a request for this in Bugzilla, so you can log a Feature
> > Request with Platform - SWT for this if you wish.
>
> Thanks, I'll do that.
>
> > An alternative which seems almost as good (at least in your context) is
to
> > populate the list on Combo FocusIn, since this typically foreshadows the
> > list being shown. I've verified that this also works for a user that
clicks
> > directly on the Combo's drop-down button while focus is on some other
> > widget.
>
> I thought of this just after I posted. Unfortunately, it appears that if I
> update the combo while in the focus event handle, the dropdown doesn't,
er,
> drop. Might be a GTK issue.
>
> Oh well. Thanks for your help anyway.
>
> jk
>
|
|
|
Powered by
FUDForum. Page generated in 0.04006 seconds