AccessibilityUIExamples/Checkbox/CustomCheckBoxViewController.swift
/* |
See LICENSE folder for this sample’s licensing information. |
Abstract: |
View controller demonstrating accessibility provided by AppKit for NSButton. |
*/ |
import Cocoa |
class CustomCheckBoxViewController: NSViewController { |
// MARK: - View Controller Lifecycle |
@IBOutlet var currentValueLabel: NSTextField! |
@IBOutlet var customCheckbox: CustomCheckBoxView! |
override func viewDidLoad() { |
super.viewDidLoad() |
// Allow the CustomCheckBoxView to call our own action function. |
customCheckbox.actionHandler = { self.changeCheckBoxValue(self) } |
} |
func changeCheckBoxValue(_ sender: Any) { |
currentValueLabel.stringValue = NSString(format: "(State = %@)", customCheckbox.checked ? "checked" : "unchecked") as String |
} |
} |
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-09-12