ドキュメントベースのアプリで最前線のウィンドウのコントロールを操作しますか?

StackOverflow https://stackoverflow.com/questions/5035303

質問

私はドキュメンテーションをスキャンし、かなり広範囲にかなり、この主題に何も見つかりませんでした。

私がする必要があるのは、私のNSWINDOWSの1つの特定のインスタンスと対話することです。つまり、Xcodeでドキュメントベースのアプリケーションを作成することで、NSDocumentシステムを介して作成されたものです。

これを行う方法はありますか?[[NSSHAREDDOCUMENTROLLER FRONTEMSWINDOW]サブビュー:DOACTION→PHERAPS?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top