Travailler avec les commandes de la fenêtre la plus façonnée dans une application basée sur des documents?
-
15-11-2019 - |
Question
J'ai scanné la documentation et j'ai googlé assez largement et n'a rien trouvé sur ce sujet.
Ce que j'ai à faire, c'est interagir avec une instance spécifique de l'une de mes nswindows - c'est-à-dire que l'on crée via le système NSDocument mis en place en créant une application basée sur des documents dans XCode.
Voilà donc un moyen de faire cela?Quelque chose comme [[NssharedddocumentController Frontwindows] Sous-View: Doaction], peut-être?
La solution
To obtain the frontmost window (aka the main window), use -[NSApplication mainWindow]
:
NSWindow *mainWindow = [NSApp mainWindow];
To obtain the window corresponding to a given document:
NSDocument *someDocument; // reference to the document you’re interested in
NSWindow *window = [[[someDocument windowControllers] objectAtIndex:0] window];
NSDocument
creates a single window controller to manage the corresponding document window, so -[NSDocument windowControllers]
returns an array with a single element corresponding to the window controller. -[NSWindowController window]
returns the window managed by that window controller.