Method getWindow doesn't work as expected

Hello, I’m having a problem with the method getWindow().

I have extended a Window class, which has its layout and a couple of buttons. I use it as a sub-window.

My problem is that when I use the function getWindow() on one of the buttons, it returns the main window instead of the sub-window.

This script is called in the constructor of the sub-window, and mainWindow is a reference to the mainWindow.
The only notification that appears is the MAIN one.

if ( button.getWindow() == mainWindow)
			mainWindow.showNotification("MAIN");
		if ( button.getWindow() == this )
			mainWindow.showNotification("SUB");

Is this right? I don’t think this is the intended behaviour. Am I missing something?

I didn’t quite understand the hierarchy of your components. Could you paste a bit more code. If a component is in a subwindow, its getWindow() should return the subwindow.