ListBox and ClickListener

19 views
Skip to first unread message

Moga

unread,
Dec 17, 2007, 11:39:56 AM12/17/07
to Google Web Toolkit
I am developing and application in which i need to fire events based
on which item in a listbox is clicked. My question is, what is the
event that a listbox sends to the onclick event handler? is it a
reference to entire listbox? or just a string of what was clicked?

Thanks

Reinier Zwitserloot

unread,
Dec 17, 2007, 12:52:13 PM12/17/07
to Google Web Toolkit
Moga, the only parameter your clicklistener gets is "Widget sender". I
don't really understand how you're not getting what that is: It's
clearly the listbox; it is a Widget (unlike strings, which aren't),
and it's clearly the 'sender'. If you then want to know what was
clicked, use the methods on listbox to figure that out.

Moga

unread,
Dec 17, 2007, 1:02:21 PM12/17/07
to Google Web Toolkit
Hello Reinier:

> and it's clearly the 'sender'. If you then want to know what was
> clicked, use the methods on listbox to figure that out.

So I guess i cannot do something like this:


ListBox.onClickListener(new ClickListener(){
onClick(Widget sender){
String myItem = (ListBox)Sender.getSelectedItem();
}
}


I need to do this because the click is caught by another composite
widget which does the processing, and it doesn't have access to this
listBox.

ps the above code is from memory, so might not be syntactically
correct.

Isaac Truett

unread,
Dec 17, 2007, 1:18:24 PM12/17/07
to Google-We...@googlegroups.com
Yes, that's what you would do. Cast the sender widget to ListBox and
get whatever you need from it.
Reply all
Reply to author
Forward
0 new messages