Is mouse button pressed NOT on widget

I have a widget looked like a usual context menu which created somewhere on a scene. How can this widget to know is mouse button was been pressed NOT on this widget to destroy it?
Like a usual context menu in windows work.
Thanks in advance.