NSDrawerWillOpenNotification
引き出しが開こうとするときの通知
解説
引き出しが開こうとするときの通知
フレームワーク
ApplicationKit
クラス
NSDrawer
使用可能
10.0
更新時のバージョン
OS X 10.10
参照
関連記事(外部サイト)
例文
//NSDrawer openOnEdge() //NSDrawer notification var theDrawer004 : MyDrawer = MyDrawer(contentSize: NSMakeSize(100.0, 100.0), preferredEdge: 1 ) //preferredEdge 0=左、1=下、2=右、3=上 func buttonAction004(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! //drawerを表示/非表示 theDrawer004.toggle(theWindow) } func buttonAction004_top(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! theDrawer004.openOnEdge(3)//上 } func buttonAction004_down(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! theDrawer004.openOnEdge(1)//下 } func buttonAction004_left(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! theDrawer004.openOnEdge(0)//左 } func buttonAction004_right(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! theDrawer004.openOnEdge(2)//右 } func handleNotification(notification: AnyObject){ NSLog("notification %@",notification.description) } @IBAction func function004(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 theButton1 : NSButton = NSButton(frame: NSMakeRect(100.0, 80.0, 100.0, 30.0)) theButton1.title = "Toggle" theButton1.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton1.action = Selector("buttonAction004:") theButton1.target = self aWindow.contentView.addSubview(theButton1) var theButton2 : NSButton = NSButton(frame: NSMakeRect(100.0, 168.0, 100.0, 30.0)) theButton2.title = "Top" theButton2.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton2.action = Selector("buttonAction004_top:") theButton2.target = self aWindow.contentView.addSubview(theButton2) var theButton3 : NSButton = NSButton(frame: NSMakeRect(100.0, 0.0, 100.0, 30.0)) theButton3.title = "Down" theButton3.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton3.action = Selector("buttonAction004_down:") theButton3.target = self aWindow.contentView.addSubview(theButton3) var theButton4 : NSButton = NSButton(frame: NSMakeRect(0.0, 80.0, 100.0, 30.0)) theButton4.title = "Left" theButton4.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton4.action = Selector("buttonAction004_left:") theButton4.target = self aWindow.contentView.addSubview(theButton4) var theButton5 : NSButton = NSButton(frame: NSMakeRect(200.0, 80.0, 100.0, 30.0)) theButton5.title = "Right" theButton5.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton5.action = Selector("buttonAction004_right:") theButton5.target = self aWindow.contentView.addSubview(theButton5) let delegateObj : DrawerDelegate = DrawerDelegate() delegateObjects.addObject(delegateObj) theDrawer004.delegate = delegateObj //テキストフィールドを作成、引き出しに付ける var textField : NSTextField = NSTextField(frame: NSMakeRect(10.0, 10.0, 50.0, 30.0)) theDrawer004.contentView?.addSubview(textField) theDrawer004.parentWindow = aWindow let nc : NSNotificationCenter = NSNotificationCenter.defaultCenter() nc.addObserver(self, selector: Selector("handleNotification:"), name: "NSDrawerDidCloseNotification", object: nil ) nc.addObserver(self, selector: Selector("handleNotification:"), name: "NSDrawerDidOpenNotification", object: nil ) nc.addObserver(self, selector: Selector("handleNotification:"), name: "NSDrawerWillCloseNotification", object: nil ) nc.addObserver(self, selector: Selector("handleNotification:"), name: "NSDrawerWillOpenNotification", object: nil ) //ウインドウの表示 aWindow.center()//ウインドウをスクリーンの中心に aWindow.title = "ウインドウタイトル"//タイトル設定 aWindow.orderFront(self)//前面に aWindow.makeKeyAndOrderFront(self)//表示 }