LookupField same field selection trigger

Hi supporters, maintainers, contributors,

About LookupField, is there possibly a way that could trigger the event when the user selects the same field (same value) of the lookupfield?
And if it exists one, could I have example code?

Thank you!

I think this little example will help.

MyLookUpField.addValueChangeListener( lookUpEvent -> { 
      if (lookUpEvent.getValue().equals(lookUpEvent.getPrevValue())) {
//Do something
}
});

Hi Andrey,

My problem is the addValueChangeListener method does NOT catch the event when the user selects a field multiple times.

An example:
My lookupField has 3 values: “Num1”, “Num2”, “Num2”. The “Num1” is the default one so it’ll be always selected at the first opening. So, when the user re-select the “Num1”, addValueChangeListener could not handle the event.

Yes, in this scenario, the listener will not fire. :frowning:
I’m not sure it can be traced.

Hi,

ValueChangeEvent is fired only then the value changed, so no way to track the selection of the same value again.

Regards,
Gleb

Ok, I’ll find another way.
Thank you!

I found a simple solution for this case.
We can use PopupButton instead and set the actions for it.

Check out the example:
https://doc.cuba-platform.com/manual-latest/gui_PopupButton.html