-
Notifications
You must be signed in to change notification settings - Fork 0
/
MacApp.swift
55 lines (47 loc) · 1.19 KB
/
MacApp.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// MacApp.swift
// AppKitGlue
//
// Created by Harry Ng on 10/1/2020.
// Copyright © 2020 StaySorted Inc. All rights reserved.
//
import Cocoa
import DynamicColor
import BonMot
// Expected
/*
class MacApp: NSObject, AppKit {
var hotKey: HotKey?
func setup() {
let hotKey = HotKey(key: .a, modifiers: [.control, .shift])
hotKey.keyDownHandler = {
print("Pressed at \(Date())")
}
self.hotKey = hotKey
}
}
*/
// Actual
class MacApp: NSObject, AppKit {
var hotKey: HotKey?
func setup() {
let hotKey = HotKey(key: .a, modifiers: [.control, .shift])
hotKey.keyDownHandler = {
self.handleKeyDown(hotKey)
}
self.hotKey = hotKey
}
func handleKeyDown(_ key: HotKey) {
print("Pressed at \(Date())")
key.keyDownHandler = {
self.handleKeyDown(key)
}
}
func viewSecondVC() {
// DynamicColor crashes by saying `Symbol not found` for NSColor
let color = DynamicColor(hexString: "#263342")
let color = NSColor(hexString: "#263342")
// BonMot crashes with initializer
let style = StringStyle()
}
}