setFrameOrigin:
ウインドウフレームの起点をセットします
- (void)setFrameOrigin:(NSPoint)point
func setFrameOrigin(_ point: NSPoint)
解説
ウインドウフレームの起点をセットします。
スクリーン座標でのウインドウの左下の位置。
ウインドウ位置は、±16,000に制限されます。
フレームワーク
ApplicationKit
クラス
NSWindow
使用可能
10.0
参照
- setFrame:display:
- setFrameTopLeftPoint:
関連記事(外部サイト)
更新時バージョン
10.10
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { [myWindow setFrameOrigin:NSMakePoint(50.0,50.0)]; } @end
//NSWindow setFrameOrigin func buttonAction052(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! NSLog("!!") theWindow.setFrameOrigin(NSMakePoint(100.0, 200.0)) NSLog("x = %.2f,y = %.2f,w = %.2f,h = %.2f", Float(theWindow.frame.origin.x ), Float(theWindow.frame.origin.y), Float(theWindow.frame.size.width), Float(theWindow.frame.size.height)) } @IBAction func function052(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 = "Action" theButton.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton.action = Selector("buttonAction052:") theButton.target = self aWindow.contentView.addSubview(theButton) //ウインドウの表示 aWindow.center()//ウインドウをスクリーンの中心に aWindow.title = "ウインドウタイトル"//タイトル設定 aWindow.orderFront(self)//前面に aWindow.makeKeyAndOrderFront(self)//表示 }