Action when closing overlay "when clicking outside"

Hello Community,

I want to show an overlay when I click a button and close it when I click outside the overlay.

The overlay has a transparent design, so I want to hide the button to open the overlay while the overlay is open.

With opening the overlay, this is no problem for me, I simply set a variable to hide the button with the click interaction on the button. However, I have trouble showing the button again when I close the overlay. It seems that there is no function to specify an action when the overlay is closed?

I also haven’t found a clean workaround, although I’ve done quite a bit of research. Adding a transparent click area around the button doesn’t seem like a clean option. Since I’m not using a full-screen overlay, there are still buttons outside that you can click while the overlay is open. When I click on such a button, not only should the overlay be closed, but also the button I just clicked should switch to an active state. I think a transparent click area would require at least two clicks?

I would be very grateful for any ideas :slight_smile: