NSWindowDelegate : windowDidBecomeKey vs windowDidBecomeMain
Asked Answered
S

1

5

What is the difference between windowDidBecomeKey: and windowDidBecomeMain: notifications?

In other words, I want to know that "what is the key window" and "what is the main window".

Stramonium answered 4/12, 2012 at 7:13 Comment(0)
O
10

From the official documentation

Windows have different looks based on how the user is interacting with them. The foremost document or application window that is the focus of the user’s attention is referred to as the main window. Each application also has only one main window at a given time. This main window often has key status, as well. The main window is the principal focus of user actions for an application. Often, user actions in a modal key window (typically a panel such as the Font window or an Info window) have a direct effect on the main window.

as an example (always from the documentation)

A good example of the difference between key and main windows can be seen in most well-behaved Mac apps. Selecting “Save As...” in a text document, for example, displays a panel with a field to type the document’s name and a pull-down menu of locations to save it. The panel represents the key window. It will accept your keyboard input (the file name), but will directly affect the main window under it (by saving it to the location you specified). Once you save the document, the save panel disappears, the main window becomes key again, and will accept keyboard input once more.

Oxycephaly answered 4/12, 2012 at 7:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.