setNextState
解説
ボタンを次の状態にします。
ボタンが3つの状態を持つなら、on/off/Mixedを循環します。
ボタンが2つの状態を持つなら、on/offを切り換えます。
フレームワーク
ApplicationKit
クラス
NSButton
使用可能
10.0
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { [myOutlet setAllowsMixedState:YES]; [myOutlet setNextState]; } @end
//NSButton setNextState var switchButton: NSButton! func buttonAction016(sender: AnyObject?){ var theWindow : NSWindow = (sender as NSButton).window! switchButton.setNextState() NSLog("!!!") } @IBAction func function016(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 theSwitch : NSButton = NSButton(frame: NSMakeRect(100.0, 90.0, 100.0, 30.0)) theSwitch.title = "Switch" theSwitch.bezelStyle = NSBezelStyle.RegularSquareBezelStyle theSwitch.setButtonType(NSButtonType.SwitchButton) theSwitch.action = Selector("buttonAction002:") theSwitch.target = self switchButton = theSwitch theSwitch.allowsMixedState = true theSwitch.state = NSMixedState aWindow.contentView.addSubview(theSwitch) var theButton : NSButton = NSButton(frame: NSMakeRect(100.0, 50.0, 100.0, 30.0)) theButton.title = "Change" theButton.bezelStyle = NSBezelStyle.RegularSquareBezelStyle theButton.action = Selector("buttonAction016:") theButton.target = self theButton.allowsMixedState = true aWindow.contentView.addSubview(theButton) aWindow.orderFront(self)//前面に aWindow.makeKeyAndOrderFront(self)//表示 }