ListSelect and click item

I want add implementation like:
click on item in ListSelect component and if is he seleted unselect it.

Is this possible for this component ?


I don’t know if i fully understood what you mean but if you want to unselect an item in a ListSelect as soon as it was clicked then you can call
in your valuechangelistener attached to the ListSelect. Also make sure NullSelectionAllowed is true.


I got ListSelect component with some items and I select one item(he is selected at now), and I want unselect this item by mouse click on it - this is impossible; I cant add any click listener to component and the valueChangeListener won’t work here.

Settings of my ListSelect


First of all: You can deselect rows by holding Ctrl when clicking on them.
Secondly: If you want to have it act like a toggle without the need to hold control you could attach a ClickListener/ValueChangelistener which checks if the currently clicked item (its ID) is part of the ListSelects Value Array and if that’s the case you can call unselect(itemID) on the clicked Item.

There is no way add clickListener to ListSelect, valueChangeListener also won’t work here(generate events only when value is change not click on it)

In that case you have to use the ValueChangeListener as the value resembels the selected items.
Can be seen
when you view the sources.
So it would be something like this:

Object[] arr = listselect.getValue();

This is not usable code btw. as i don’t know the methods by heart.