macOS/iOS API解説

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

目次

openOnEdge:

INDEX>AppKit>NSDrawer

端を指定して引き出しを開きます

Objective-C

- (void)openOnEdge:(NSRectEdge)edge

Swift

func openOnEdge(_ edge: NSRectEdge)

解説

引き出しの端を指定して開きます。
【NSRectEdge】ウインドウの端
0=左、1=下、2=右、3=上
● NSMinXEdge 左
f:id:jjj777:20150405170344p:plain
● NSMinYEdge 下
f:id:jjj777:20150405170428p:plain
● NSMaxXEdge 右
f:id:jjj777:20150405170407p:plain
● NSMaxYEdge 上
f:id:jjj777:20150405170320p:plain


www.youtube.com

返り値

( void )

なし

引数


Objective-C

(NSRectEdge)edge

Swift
0=左、1=下、2=右、3=上

(_ edge: NSRectEdge)

フレームワーク

ApplicationKit

クラス

NSDrawer

使用可能

10.0

参照

更新時のバージョン

OS X 10.10.2

関連記事(外部サイト)

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction1:(id)sender
{
[drawer openOnEdge:NSMinYEdge];
}

- (IBAction)myAction2:(id)sender
{
[drawer close:nil];
}

@end

Swift

    //NSDrawer openOnEdge()
    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)//右
    }
    @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
        
        //ウインドウの表示
        aWindow.center()//ウインドウをスクリーンの中心に
        aWindow.title = "ウインドウタイトル"//タイトル設定
        aWindow.orderFront(self)//前面に
        aWindow.makeKeyAndOrderFront(self)//表示
    }