1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 17:08:39 +00:00

escape button implemented

This commit is contained in:
Serg 2018-04-10 17:57:51 +07:00
parent fe5705627f
commit 651ddbef5c
4 changed files with 3 additions and 8 deletions

View File

@ -38,6 +38,7 @@ struct BarItemDefinition: Decodable {
class SupportedTypesHolder {
typealias ParametersDecoder = (Decoder) throws ->(item: ItemType, action: ActionType)
private var supportedTypes: [String: ParametersDecoder] = [
"escape": { _ in return (item: .staticButton(title: "esc"), action: .keyPress(keycode: 53)) },
"brightnessUp": { _ in return (item: .staticButton(title: "🔆"), action: .keyPress(keycode: 113)) },
"exitTouchbar": { _ in return (item: .staticButton(title: "exit"), action: .exitTouchbar) },
]

View File

@ -29,10 +29,6 @@ extension KeyPress {
}
}
struct ESCKeyPress: KeyPress {
let keyCode: CGKeyCode = 53
}
struct BrightnessUpPress: KeyPress {
let keyCode: CGKeyCode = 113
}

View File

@ -40,7 +40,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
loadItems()
touchBar.delegate = self
touchBar.defaultItemIdentifiers = Array(items.keys)
self.presentTouchBar()
}
@ -59,6 +58,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
let identifier = NSTouchBarItem.Identifier(identifierString)
items[identifier] = item
touchBar.defaultItemIdentifiers += [identifier]
}
}
@ -103,9 +103,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
}
switch identifier {
case .escButton:
return CustomButtonTouchBarItem(identifier: identifier, title: "esc", key: ESCKeyPress())
case .brightUp:
return CustomButtonTouchBarItem(identifier: identifier, title: "🔆", key: BrightnessUpPress())
case .brightDown:

View File

@ -1,4 +1,5 @@
[
{ "type": "escape" },
{ "type": "brightnessUp" },
{ "type": "exitTouchbar" },
]