Re: Getting the currently selected item in a ListBox

2009-12-15 Thread jax
OK, thanks for clarifying this issue for me.

-jack

On Dec 15, 4:45 pm, Paul Robinson  wrote:
> It's a timing issue - having used a MouseUpHandler, you're assuming the
> list box will already have handled the MouseUp event before you get
> called (which it looks like it doesn't).
>
> Use a ChangeHandler instead - this will be called after the ListBox has
> handled the change.
>
> Also, if you were to use a MouseUpHandler, then you wouldn't get events
> relating to the listbox changing through the keyboard. ChangeHandler
> gets changes regardless of how they occur.
>
> Paul
>
> jaxwrote:
> > This seems like a silly question but it does not work for me.
>
> > When I use .getSelectedIndex() on a ListBox it returns the previously
> > selected item in history, not the one I selected just now.
>
> > What is going on?
>
> >            cmbDefinitionSelection.addMouseUpHandler(new MouseUpHandler() {
> >                    public void onMouseUp(MouseUpEvent event) {
> >                            int index = 
> > cmbDefinitionSelection.getSelectedIndex();
> >                            
> > txtDefinition.setText(cmbDefinitionSelection.getItemText(index));
> >                    }
> >            });
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-web-tool...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > google-web-toolkit+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/google-web-toolkit?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.




Re: Getting the currently selected item in a ListBox

2009-12-15 Thread Paul Robinson
It's a timing issue - having used a MouseUpHandler, you're assuming the
list box will already have handled the MouseUp event before you get
called (which it looks like it doesn't).

Use a ChangeHandler instead - this will be called after the ListBox has
handled the change.

Also, if you were to use a MouseUpHandler, then you wouldn't get events
relating to the listbox changing through the keyboard. ChangeHandler
gets changes regardless of how they occur.

Paul

jax wrote:
> This seems like a silly question but it does not work for me.
>
> When I use .getSelectedIndex() on a ListBox it returns the previously
> selected item in history, not the one I selected just now.
>
> What is going on?
>
>   cmbDefinitionSelection.addMouseUpHandler(new MouseUpHandler() {
>   public void onMouseUp(MouseUpEvent event) {
>   int index = 
> cmbDefinitionSelection.getSelectedIndex();
>   
> txtDefinition.setText(cmbDefinitionSelection.getItemText(index));
>   }
>   });
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
>
>   

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.




Getting the currently selected item in a ListBox

2009-12-15 Thread jax
This seems like a silly question but it does not work for me.

When I use .getSelectedIndex() on a ListBox it returns the previously
selected item in history, not the one I selected just now.

What is going on?

cmbDefinitionSelection.addMouseUpHandler(new MouseUpHandler() {
public void onMouseUp(MouseUpEvent event) {
int index = 
cmbDefinitionSelection.getSelectedIndex();

txtDefinition.setText(cmbDefinitionSelection.getItemText(index));
}
});

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.