preventsApplicationTerminationWhenModal
ウインドウがモーダルの時に、終了を防ぐかどうか
@property BOOL preventsApplicationTerminationWhenModal
var preventsApplicationTerminationWhenModal: Bool
解説
このウインドウがモーダルの時に、アプリケーションの終了を出来ないようにするかどうかの設定
trueの場合の挙動 終了できない。
falseの場合の挙動 終了できる
フレームワーク
Appkit
クラス
NSWindow
使用可能
10.6
参照
例文
//NSWindow preventsApplicationTerminationWhenModal func abortTimer019(timer:NSTimer!) { NSLog("abort modal") let anApplication = NSApplication.sharedApplication() var p :MyPanel = timer.userInfo?.objectForKey("panel") as MyPanel if (p.worksWhenModal){ NSLog("panel worksWhenModal YES") }else{ NSLog("panel worksWhenModal NO") } NSLog("%@",p.title!) p.orderOut(self) //modal stop anApplication.abortModal() } @IBAction func function019(sender: AnyObject) { var panel : MyPanel = MyPanel( contentRect: NSMakeRect(0.0, 0.0, 300, 200), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false) windowArray.addObject(panel) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄 panel.preventsApplicationTerminationWhenModal = true //終了できない //panel.preventsApplicationTerminationWhenModal = false //終了できる panel.center()//ウインドウをスクリーンの中心に panel.title = "ウインドウタイトル"//タイトル設定 //text field var textField : NSTextField = NSTextField(frame: NSMakeRect(50.0, 50.0, 100.0, 30.0)) panel.contentView.addSubview(textField) panel.orderFront(self)//前面に //タイマー var timer = NSTimer.scheduledTimerWithTimeInterval(30.0, target: self, selector: Selector("abortTimer019:"), userInfo: ["panel":panel], repeats: false) //タイマー、モーダルに入るとタイマーが動かなくなるので、ランループに追加する NSRunLoop.currentRunLoop().addTimer(timer, forMode: NSRunLoopCommonModes) let anApplication = NSApplication.sharedApplication() //モーダル開始 var result:NSModalResponse = anApplication.runModalForWindow(panel) }
更新時のバージョン
OS X 10.10