state
解説
ボタンの状態を返します。
【ボタンの状態】
● NSOnState on
● NSOffState off
● NSMixedState Mixed
ボタンがMixedの状態を使うには、allowsMixedState:メソッドを使います。
フレームワーク
ApplicationKit
クラス
NSButton
使用可能
10.0
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { [myOutlet setAllowsMixedState:YES]; switch ( [myOutlet state] ){ case NSMixedState: [myOutlet setTitle:@"mix"]; break; case NSOffState: [myOutlet setTitle:@"off"]; break; case NSOnState: [myOutlet setTitle:@"on"]; break; } } @end
//NSButton state @IBAction func function015(sender: AnyObject) { var aWindow : NSWindow = NSWindow(contentRect: NSMakeRect(0.0, 0.0, 300.0, 200.0), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false, screen: NSScreen.mainScreen()) windowArray.addObject(aWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄 aWindow.center()//ウインドウをスクリーンの中心に aWindow.title = "ウインドウタイトル"//タイトル設定 // var theButton : NSButton = NSButton(frame: NSMakeRect(100.0, 90.0, 100.0, 30.0)) theButton.title = "Change" theButton.bezelStyle = NSBezelStyle.RegularSquareBezelStyle theButton.setButtonType(NSButtonType.SwitchButton) theButton.action = Selector("buttonAction002:") theButton.target = self theButton.allowsMixedState = true theButton.state = NSMixedState //NSOnState //NSOffState aWindow.contentView.addSubview(theButton) aWindow.orderFront(self)//前面に aWindow.makeKeyAndOrderFront(self)//表示 }