Combobox Eventlistener should only be called on user selection and not on s

Hi,

i have a ComboBox with a ValueChangeEventListener. The ValueChangeListener gets a ValueChangeEvent when you manually select a value in the ComboBox with a mouse as well as when you call the select() method in code.

Is there a way to set the value without sending a ValueChangeEvent when you programatically set the value of the combobox? I only want change events from the user that manually selected a value but not if i select it from code.

Thanks!

Hi,

AFAIK there isn’t such a mechanism available, but I have many times discussed of such an enhancement. The usual workarounds are to implement it to your extended component (and have a flag that keeps trac if the execution is currently in public setValue API call) or just remove/reattach listeners as needed.

I created this issue for the feature, feel free to add you own insight there:
https://dev.vaadin.com/ticket/19477#ticket

cheers,
matti

Hi,

there is an easy solution, no idea why i did not do it like this earlier:

[code]
comboBox.addFocusListener(new FocusListener() {

        @Override
        public void focus(FocusEvent event) {
            comboBox.addValueChangeListener(listener);
        }
    });
    comboBox.addBlurListener(new BlurListener() {
        
        @Override
        public void blur(BlurEvent event) {
            comboBox.removeValueChangeListener(listener);
        }
    });

[/code]With this the listener is only called when i select a value from hand and not with setvalue or select