I am making a application that the user will have to interact with one window and when they have that window configured the way they want it they switch to a different application then my application will begin to do other stuff which i will have defined in a method
say for an example program when the main window has focus it contains a label that says “i am focused” and when the person clicks on the desktop or another window/application then the label will read “i am not focused”.
Thanks
That is not the same as key window. Key window means that you will receive input events for your application. What you want to know is whether your application is in the foreground. What you’re looking for is the
NSApplicationnotificationsNSApplicationDidBecomeActiveNotificationandNSApplicationDidResignActiveNotification. Observe those to discover when your application is or isn’t in the foreground. Your application delegate’sapplicationDidBecomeActive:andapplicationDidResignActive:will automatically be called on these events.