attachedSheet
ウインドウに付けられたシート
@property(readonly, strong) NSWindow *attachedSheet
var attachedSheet: NSWindow? { get }
解説
ウインドウにシートがついてなければnilを返します
設定値
@property(readonly, strong) NSWindow *attachedSheet
var attachedSheet: NSWindow? { get }
ウインドウ
フレームワーク
ApplicationKit
クラス
NSWindow
使用可能
10.1
参照
関連記事(外部サイト)
更新時バージョン
10.10
例文
[[self window] attachedSheet] // #import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { if ([myWindow attachedSheet] != nil ){ NSLog([[myWindow attachedSheet] description]); }else{ NSLog(@"Nil"); } } @end
//NSWindow beginSheet:completionHandler: //NSWindow attachedSheet func buttonAction042_2(sender: AnyObject){ //シートの親ウインドウ let parentWindow : NSWindow = (sender as NSButton).window!.sheetParent! if (parentWindow.attachedSheet != nil){ NSLog("attachedSheet %@", parentWindow.attachedSheet!) //->attachedSheet <NSWindow: 0x6080001e0900> } //シートの親ウインドウに対して、シートの終了 parentWindow.endSheet((sender as NSButton).window!, returnCode: NSModalResponseStop ) // NSModalResponseStop = (-1000), // NSModalResponseAbort = (-1001), // NSModalResponseContinue = (-1002), } func buttonAction042(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! var sheetWindow : NSWindow = NSWindow( contentRect: NSMakeRect(0.0, 0.0, 200, 150), styleMask: NSBorderlessWindowMask, backing: .Buffered, defer: false) sheetWindow.backgroundColor = NSColor.redColor() //ボタンを作成 var sheetButton : NSButton = NSButton(frame: NSMakeRect(50.0, 2.0, 80.0, 30.0)) sheetButton.title = "Close" sheetButton.bezelStyle = NSBezelStyle.RoundedBezelStyle sheetButton.action = Selector("buttonAction042_2:") sheetWindow.contentView.addSubview(sheetButton) theWindow.beginSheet(sheetWindow, completionHandler:{responseCode in if (responseCode == NSModalResponseStop) { NSLog("NSModalResponseStop") }else{ NSLog("Other") } }) } @IBAction func function042(sender: AnyObject) { var aWindow : NSWindow = NSWindow( contentRect: NSMakeRect(0.0, 0.0, 300, 200), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false) windowArray.addObject(aWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄 //ボタンを作成 var theButton : NSButton = NSButton(frame: NSMakeRect(100.0, 2.0, 100.0, 30.0)) theButton.title = "Sheet" theButton.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton.action = Selector("buttonAction042:") aWindow.contentView.addSubview(theButton) //ウインドウの表示 aWindow.center()//ウインドウをスクリーンの中心に aWindow.title = "ウインドウタイトル"//タイトル設定 aWindow.orderFront(self)//前面に }