AbstractSelectionModel.setSelected() schedules selection change event
to be fired at the end of the current event loop, so a new event will
be fired after onSelectionChange() is executed.

On Dec 23, 2:24 pm, "Jaroslav Z?ruba" <jaroslav.zar...@gmail.com>
wrote:
> Hello
>
> I'm trying to clear selection on a list that has selectionChangeHandler
> attached to it. This fires a new event that triggers the handler again. I'd
> like to ignore the event that has been triggered as result of me clearing
> the selection.
> The problem is that there seems to be stuff happening asynchronously.
>
> new SelectionChangeEvent.Handler()
> {
> boolean muted = false;
>
> @SuppressWarnings("unchecked")
> @Override
> public void onSelectionChange(SelectionChangeEvent event)
> {
> if(muted)
> return;
>
> NoSelectionModel<User> selectionModel = (NoSelectionModel<User>)
> event.getSource();
> User user = selectionModel.getLastSelectedObject();
> // ...
>
> muted = true;
> // I'd expect the following line to launch onSelectionChange again, with
> muted=true
> selectionModel.setSelected(user, false);
> // instead following one gets evaluated
> muted = false;
> // and the handler gets triggered after that, obviously with muted=false
> again :(
>
> }
> }
>
> I could check whether the user is null and return out of the handler but I
> don't like that kind of workaround because null selection != invalid
> selection; and (more importantly) this ?async? evaluation does not seem
> right...
> What am I missing please?
>
>   J. Záruba

-- 
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.

Reply via email to