setFrameTopLeftPoint:
フレームの左上の座標をセットします
- (void)setFrameTopLeftPoint:(NSPoint)pointfunc setFrameTopLeftPoint(_ point: NSPoint)
解説
スクリーン座標でウインドウの左上の位置をセットします。
ウインドウ位置は±16,000に制限されます。
返り値
なし
引数
セットする左上の位置
Objective-C- (void)setFrameTopLeftPoint:(NSPoint)pointfunc setFrameTopLeftPoint(_ point: NSPoint)
フレームワーク
ApplicationKit
クラス
NSWindow
使用可能
10.0
参照
- cascadeTopLeftFromPoint:
- setFrame:display:
- setFrameOrigin:
関連記事(外部サイト)
更新時バージョン
10.10
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { [myWindow setFrameTopLeftPoint:NSMakePoint(50.0,50.0)]; } @end
//NSWindow setFrameTopLeftPoint() func buttonAction053(sender: AnyObject){ var theWindow : NSWindow = (sender as NSButton).window! NSLog("!!") theWindow.setFrameTopLeftPoint(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 function053(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("buttonAction053:") theButton.target = self aWindow.contentView.addSubview(theButton) //ウインドウの表示 aWindow.center()//ウインドウをスクリーンの中心に aWindow.title = "ウインドウタイトル"//タイトル設定 aWindow.orderFront(self)//前面に aWindow.makeKeyAndOrderFront(self)//表示 }