Detect click

Hello everyone,

Is it possible to detect a click outside my custome widget element?

and if it is possible, how can I do it?

my version is 2021.1 enterprise

Thanks!!