AutoHideEnabled Window


I am looking for a window which closes itself when the user clickes outside the window (not modal) which seems to be a common requirement. The click outside the window should still be effective (e.g. clicking on a button outside the window should trigger the button click AND close the window).
I did not find a suitable addon and I know that PopupButton behaves like this but I want to open the window without the use of a button.

How would I implement this behavior?
Would it be enough to implement a widget e.g. extend a Window and set VWindow.
to true?

Thanks in advance.