ListSelect and click item

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

Is this possible for this component ?

Thanks

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
unselect(itemId)
in your valuechangelistener attached to the ListSelect. Also make sure NullSelectionAllowed is true.

Again,

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

setMultiSelect(true);
setNullSelectAllowed(true);
setImmediate(true);

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
here
when you view the sources.
So it would be something like this:

listselect.addValueChangeListener(....{
Object[] arr = listselect.getValue();
if(arr.contains(event.getSelectedValue()))
  listselect.getItem(event.getSelectedValue()).unselect()
});

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