Last active
January 22, 2020 13:52
-
-
Save Akemi/0c124a4a3eb4f28a2132be7dc3fae91b to your computer and use it in GitHub Desktop.
touch bar NSSliderTouchBarItem problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
extension NSTouchBarItem.Identifier { | |
static let sliderTest = NSTouchBarItem.Identifier("test.bar.slider") | |
} | |
extension NSTouchBar.CustomizationIdentifier { | |
static let testBar = NSTouchBar.CustomizationIdentifier("test.bar") | |
} | |
class App: NSApplication, NSApplicationDelegate, NSTouchBarDelegate { | |
func applicationDidFinishLaunching(_ notification: Notification) { | |
NSApp.setActivationPolicy(.regular) | |
atexit_b { NSApp.setActivationPolicy(.prohibited) } | |
NSApp.activate(ignoringOtherApps: true) | |
} | |
override func makeTouchBar() -> NSTouchBar? { | |
let touchBar = NSTouchBar() | |
touchBar.delegate = self | |
touchBar.customizationIdentifier = .testBar | |
touchBar.defaultItemIdentifiers = [.sliderTest] | |
touchBar.customizationAllowedItemIdentifiers = [.sliderTest] | |
return touchBar | |
} | |
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? { | |
switch identifier { | |
case NSTouchBarItem.Identifier.sliderTest: | |
let tbItem = NSSliderTouchBarItem(identifier: identifier) | |
tbItem.customizationLabel = "test"; | |
return tbItem; | |
default: | |
return nil | |
} | |
} | |
} | |
let app = App.shared | |
NSApp = app | |
app.delegate = app as? NSApplicationDelegate | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment