Register addListener in my component

I have a class that extends VerticalLayout with various TextFields and Buttons. I need to know when a button inside this class is clicked outside of the class. I have made this method in my class:

            ComponentEventListener<ClickEvent<MenuItem>> listener) {
        return saveInterfaceButton.addClickListener(listener);

I have this code in my constructor of the view:
```InterfaceLayout interfaceLayout = new InterfaceLayout();
            System.out.println("Is listening?");
Any tips to why this doesn't work.

This seems like a fine way to fire a global event accross all instances of a component and I could try to implement this, but I have a feel that there should be a easier way to do this when components is child of a component. A Button have the method Register addClickListener which can be called from a view, why can this not be relayed out through another component like I tried? ButtonClickEvent->MyClassClickEvent->MyViewClickHandler. A short explanation why I can’t do this would be great!

Looking at your code it looks totally fine and I don’t see any reasons why it shouldn’t work. You are just delegating the registration call

Thanks for acknowledging that the snippets should work. Due to this I figured that the error must be somewhere else, and it was a rookie one :wink: Good I’m still a rookie. I had, for some reason, added the new constructor two times and in between I had added the listener.:grimacing: