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:
parent
fe5705627f
commit
651ddbef5c
@ -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) },
|
||||
]
|
||||
|
||||
@ -29,10 +29,6 @@ extension KeyPress {
|
||||
}
|
||||
}
|
||||
|
||||
struct ESCKeyPress: KeyPress {
|
||||
let keyCode: CGKeyCode = 53
|
||||
}
|
||||
|
||||
struct BrightnessUpPress: KeyPress {
|
||||
let keyCode: CGKeyCode = 113
|
||||
}
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
[
|
||||
{ "type": "escape" },
|
||||
{ "type": "brightnessUp" },
|
||||
{ "type": "exitTouchbar" },
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user