Michael
(Michael Grove)
February 25, 2011, 3:41pm
1
There does not seem to be a way to attach a listener in order to recieve mouse events, specifically, i’m interested in double click events.
I’ve tried these different methods, and none of them seem to work. Any suggestions?
Thanks.
mList.addListener(new Component.Listener() {
public void componentEvent(final Event theEvent) {
System.err.println("list component event: " + theEvent);
if (theEvent instanceof MouseEvents.ClickEvent) {
System.err.println("Mouse click! " + ((MouseEvents.ClickEvent)theEvent).isDoubleClick());
}
}
});
mList.addListener(MouseEvents.ClickEvent.class, this, "click");
mList.addListener(ItemClickEvent.class, this, "click");
Michael
(Michael Grove)
February 25, 2011, 3:48pm
2
ah, you have to attach a LayoutClickListener on the parent container, that seems to work, but that’s very unintuitive.
Johannes60
(Johannes Lehnert)
July 16, 2014, 11:03am
3
Hi
I have nearly the same problem. I also noticed that I can listen to mouseclicks when I add a clicklistener to the panel behind the ListSelect. But I don’t see a good way to identify the clicked item, respectively whether an item was clicked or not. When an item is newly selected I have the ValueChangeEvent in the ListSelect, but that’s not always the case.
What I want to achieve is, that I can confirm a choice with doubleclick as I do with enter. Is there any way? Any idea?
Vikas15
(Vikas Goel)
July 3, 2015, 11:00am
4
I also have a similar requirement. I want to differentiate between single click which invokes ValueChange Event and double click. Is there any way to do this effectively?
Evgeniy23
(Evgeniy Dosaev)
July 25, 2017, 6:28am
5
I also had a similar requirement. My solution:
public Component createPopUp() {
String string1 = “string1”;
String string2 = “string2”;
final VerticalLayout popupContent = new VerticalLayout();
final ListSelect select = new ListSelect();
select.addItem(string1);
select.addItem(string2);
select.setRows(2);
select.setNullSelectionAllowed(false);
select.addStyleName("hide-vertical-scroll");
//add in css
/*.hide-vertical-scroll select {
overflow-y: hidden;
}*/
popupContent.addComponent(select);
final PopupView popup = new PopupView(FontAwesome.BOOKMARK.getHtml(), popupContent);
popup.setCaptionAsHtml(true);
popup.setHideOnMouseOut(false);
select.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (event.getProperty().getValue().toString().equals(string1)) {
//business logic
}
else if (event.getProperty().getValue().toString().equals(string2)) {
//business logic
}
popupContent.setVisible(false);
select.setValue(null);
}
});
popup.addPopupVisibilityListener(new PopupVisibilityListener() {
@Override
public void popupVisibilityChange(PopupVisibilityEvent event) {
popupContent.setVisible(true);
}
});
return popup;
}