New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce getListeners(eventType) method on com.vaadin.flow.component.ComponentEventBus #9766
Comments
It should be quite straight forward to introduce the a similar API to https://github.com/vaadin/framework/blob/master/server/src/main/java/com/vaadin/server/AbstractClientConnector.java#L1174 |
Any news on this? We also need to be able to check if a KeyEventListener exists for a specific key.
With Vaadin Flow the only way I see - without reflection - is to overwrite addKeyPressListener.
Thanks |
@retomerz it's tagged with |
Introduce getListeners(eventType) method on com.vaadin.flow.component.ComponentEventBus and shorthand method on com.vaadin.flow.component.Component fixes: #9766
Introduce getListeners(eventType) method on com.vaadin.flow.component.ComponentEventBus and shorthand method on com.vaadin.flow.component.Component fixes: #9766
I've added support for getListeners, but as for your second issue - getting KeyCode from listener - even if now we have access to listeners the key property is not accessible. I could add just a getter for it but I don't see wider usecase for it. As a workaround you can do sth like:
|
This ticket/PR has been released with Vaadin 23.2.0.beta1 and is also targeting the upcoming stable 23.2.0 version. |
With Vaadin 8.x it was possible to use com.vaadin.server.AbstractClientConnector#getListeners
It is not possible to access the listeners with Vaadin Flow without reflection.
Please re-introduce a getListeners(eventType) method on com.vaadin.flow.component.ComponentEventBus
in Vaadin Flow 14.x
In our case, we need it to record user interaction with a component.
For example a click via click listener.
For this, every component will add an "internal" click listener.
On layouts (like VerticalLayout) the interaction is only recorded if another click listener (!= internal) is registered.
So basically the internal click listener checks for "getListeners(ClickEvent.class) > 1" on click event.
And only if more than one click listener is added, the click is recorded.
What we already have tested:
Temporary remove our internal click listener and then call "hasListener".
But the problem is that this will change the listener order.
Our internal click listener must be always fired as the first.
Another possible solution would be to override all add(Click)Listener methods and track it by our self.
But that feels a bit poor
The text was updated successfully, but these errors were encountered: