Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Hook combo box dropdown event
Hook combo box dropdown event [message #452759] Thu, 24 March 2005 15:32 Go to next message
John Krasnay is currently offline John KrasnayFriend
Messages: 2
Registered: July 2009
Junior Member
Hello all.

I'm using a Combo widget, the contents of which depends on state in another
part of the window. The problem is that the contents are expensive to
compute,
so I'd like to only do that in a lazy fashion, just before the dropdown
list
is displayed.

Does anyone have any idea how to do this?

I've tried using a MouseListener to listen for mouseDown events, but they
are
not fired when clicking on the dropdown button.

BTW I'm on the Linux GTK platform, but of course I'm looking for a portable
solution.

Thanks.

jk
Re: Hook combo box dropdown event [message #452768 is a reply to message #452759] Thu, 24 March 2005 15:54 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi John,

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.

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.

Grant

"John Krasnay" <john@krasnay.ca> wrote in message
news:ba7a4b82f3818028a82919ea842adbb7$1@www.eclipse.org...
> Hello all.
>
> I'm using a Combo widget, the contents of which depends on state in
another
> part of the window. The problem is that the contents are expensive to
> compute,
> so I'd like to only do that in a lazy fashion, just before the dropdown
> list
> is displayed.
>
> Does anyone have any idea how to do this?
>
> I've tried using a MouseListener to listen for mouseDown events, but they
> are
> not fired when clicking on the dropdown button.
>
> BTW I'm on the Linux GTK platform, but of course I'm looking for a
portable
> solution.
>
> Thanks.
>
> jk
>
Re: Hook combo box dropdown event [message #452838 is a reply to message #452768] Thu, 24 March 2005 20:46 Go to previous messageGo to next message
John Krasnay is currently offline John KrasnayFriend
Messages: 2
Registered: July 2009
Junior Member
> 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
Re: Hook combo box dropdown event [message #452911 is a reply to message #452838] Mon, 28 March 2005 14:27 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
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
>
Previous Topic:Using Browser Widget as report viewer, is it good approach ?
Next Topic:Text widget mac osx does not grey out
Goto Forum:
  


Current Time: Tue Nov 12 18:18:17 GMT 2019

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

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

Back to the top