Croo
Croo

Reputation: 1371

Correctly sink click event

I'm trying to create an expandable and selectable row element in GWT. This row contains an expand icon which I can click on to expand the row. I can also click on each row to select it.

My problem is that if I click on the expand icon I always trigger the row selection event too and I don't want that. How can I sink the click event so that if I click on the expand icon, only the expand will occur, but not the selection?

The green row is selected:

A row selected

When I expand a row I also trigger the selection with the click and my selection move(bad):

enter image description here

This is what I want: I expand with the plus icon, without changing in the selection(yay!) :

enter image description here

I tried to use expandIcon.sinkEvent(Event.ONCLICK); but it didn't help. How can I do this?

Upvotes: 3

Views: 1453

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

To prevent the click event from bubbling up to the parent widget, you'd want to stopPropagation() when handling it at the expandIcon level.

Upvotes: 5

Related Questions