An event when clicking in a window

I continue learning ASOC.
Here is a new test. I click on a button to open a second window and to change alpha for the first window.
Something like :

	secondWindow's makeKeyAndOrderFront_(sender)
	mainWindow's setAlphaValue_(0.7)

But it would be nice to recover the original alpha value when clicking back on mainWindow.
I try using on mouseUp_ or on mouseEntered_ but it doesn’t do anything.
Or if I create a function changeAlpha_(), I don’t know where to hook it up.

Any idea? It’s probably very simple but i’m stucked :slight_smile:
Thanks a lot.

You can register to receive notifications for NSWindowDidBecomeKeyNotification and NSWindowDidResignKeyNotification. Then code accordingly.