Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out whether an NSWindow is active

Tags:

macos

cocoa

How can I find out if an NSWindow is active? i.e. if I have some windows on the desktop then only one is active and has colored window buttons and receives keyboard and mouse events. How can I find out if my window is the active one? To find out if the window is miniaturized there is the isMiniaturized method.

like image 847
Jochen Avatar asked Dec 22 '22 10:12

Jochen


1 Answers

You are looking for NSWindow's -isKeyWindow method. "is key" means that it receives keyboard events.

like image 178
Richard Avatar answered Jan 24 '23 10:01

Richard