1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-12 01:48:38 +00:00
MTMR/MTMR/CustomButtonTouchBarItem.swift

35 lines
912 B
Swift

//
// TouchBarItems.swift
// MTMR
//
// Created by Anton Palgunov on 18/03/2018.
// Copyright © 2018 Anton Palgunov. All rights reserved.
//
import Cocoa
class CustomButtonTouchBarItem: NSCustomTouchBarItem {
let tapClosure: () -> ()
private(set) var button: NSButton!
init(identifier: NSTouchBarItem.Identifier, title: String, onTap callback: @escaping () -> ()) {
self.tapClosure = callback
super.init(identifier: identifier)
button = NSButton(title: title, target: self, action: #selector(didTapped))
button.font = .systemFont(ofSize: CGFloat(13.0))
button.title = title
self.view = button
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func didTapped() {
self.tapClosure()
let hf: HapticFeedback = HapticFeedback()
hf.tap(strong: 6)
}
}