macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

sheets

INDEX>AppKit> NSWindow

Objective-C

@property(readonly, copy) NSArray *sheets

Swift

var sheets: [AnyObject] { get }

解説

ウインドウに付いているシート

attachedSheetは一番上に表示されているシート

返り値

Objective-C

Swift


    

フレームワーク

ApplicationKit

クラス

NSWindow

使用可能

参照

関連記事(外部サイト)

例文

Objective-C

Swift

    //NSWindow beginCriticalSheet
    //NSWindow sheets
    func buttonAction043_2(sender: AnyObject){
        //シートの親ウインドウ
        let parentWindow : NSWindow = (sender as NSButton).window!.sheetParent!

        if (parentWindow.sheets.count > 0 ){
            for value in parentWindow.sheets {
                NSLog("sheets = %@", (value.description))
            }
        }
        
        if (parentWindow.attachedSheet != nil){
            NSLog("attachedSheet %@", parentWindow.attachedSheet!)
            //->attachedSheet <NSWindow: 0x6080001e0900>
        }
        //シートの親ウインドウに対して、シートの終了
        parentWindow.endSheet((sender as NSButton).window!)

    }
    func buttonAction043(sender: AnyObject){
        
        var theWindow : NSWindow = (sender as NSButton).window!
        var sheetWindow1 : NSWindow = NSWindow(
            contentRect: NSMakeRect(0.0, 0.0, 200, 150),
            styleMask: NSBorderlessWindowMask,
            backing: .Buffered,
            defer: false)
        sheetWindow1.backgroundColor = NSColor.blueColor()
        //ボタンを作成
        var sheetButton1 : NSButton = NSButton(frame: NSMakeRect(50.0, 2.0, 80.0, 30.0))
        sheetButton1.title = "Close"
        sheetButton1.bezelStyle = NSBezelStyle.RoundedBezelStyle
        sheetButton1.action = Selector("buttonAction043_2:")
        sheetWindow1.contentView.addSubview(sheetButton1)
        
        var sheetWindow2 : NSWindow = NSWindow(
            contentRect: NSMakeRect(0.0, 0.0, 200, 150),
            styleMask: NSBorderlessWindowMask,
            backing: .Buffered,
            defer: false)
        sheetWindow2.backgroundColor = NSColor.yellowColor()
        //ボタンを作成
        var sheetButton2 : NSButton = NSButton(frame: NSMakeRect(50.0, 2.0, 80.0, 30.0))
        sheetButton2.title = "Close"
        sheetButton2.bezelStyle = NSBezelStyle.RoundedBezelStyle
        sheetButton2.action = Selector("buttonAction043_2:")
        sheetWindow2.contentView.addSubview(sheetButton2)
        
        var sheetWindow3 : NSWindow = NSWindow(
            contentRect: NSMakeRect(0.0, 0.0, 150, 100),
            styleMask: NSBorderlessWindowMask,
            backing: .Buffered,
            defer: false)
        sheetWindow3.backgroundColor = NSColor.redColor()
        //ボタンを作成
        var sheetButton3 : NSButton = NSButton(frame: NSMakeRect(50.0, 2.0, 80.0, 30.0))
        sheetButton3.title = "Close"
        sheetButton3.bezelStyle = NSBezelStyle.RoundedBezelStyle
        sheetButton3.action = Selector("buttonAction043_2:")
        sheetWindow3.contentView.addSubview(sheetButton3)
        
        var sheetWindow4 : NSWindow = NSWindow(
            contentRect: NSMakeRect(0.0, 0.0, 200, 150),
            styleMask: NSBorderlessWindowMask,
            backing: .Buffered,
            defer: false)
        sheetWindow4.backgroundColor = NSColor.greenColor()
        //ボタンを作成
        var sheetButton4 : NSButton = NSButton(frame: NSMakeRect(50.0, 2.0, 80.0, 30.0))
        sheetButton4.title = "Close"
        sheetButton4.bezelStyle = NSBezelStyle.RoundedBezelStyle
        sheetButton4.action = Selector("buttonAction043_2:")
        sheetWindow4.contentView.addSubview(sheetButton4)
        
        theWindow.beginSheet(sheetWindow1, completionHandler:{responseCode  in
            NSLog("sheet1")
        })
        
        theWindow.beginSheet(sheetWindow4, completionHandler:{responseCode  in
            NSLog("sheet4")
        })
        
        theWindow.beginCriticalSheet(sheetWindow3, completionHandler:{responseCode  in
            NSLog("sheet3")
        })

        theWindow.beginSheet(sheetWindow2, completionHandler:{responseCode  in
            NSLog("sheet2")
        })

    }
    @IBAction func function043(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("buttonAction043:")
        aWindow.contentView.addSubview(theButton)
        
        
        
        //ウインドウの表示
        aWindow.center()//ウインドウをスクリーンの中心に
        aWindow.title = "ウインドウタイトル"//タイトル設定
        aWindow.orderFront(self)//前面に

    }

更新時バージョン