mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
escape button implemented
This commit is contained in:
parent
fe5705627f
commit
651ddbef5c
@ -38,6 +38,7 @@ struct BarItemDefinition: Decodable {
|
|||||||
class SupportedTypesHolder {
|
class SupportedTypesHolder {
|
||||||
typealias ParametersDecoder = (Decoder) throws ->(item: ItemType, action: ActionType)
|
typealias ParametersDecoder = (Decoder) throws ->(item: ItemType, action: ActionType)
|
||||||
private var supportedTypes: [String: ParametersDecoder] = [
|
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)) },
|
"brightnessUp": { _ in return (item: .staticButton(title: "🔆"), action: .keyPress(keycode: 113)) },
|
||||||
"exitTouchbar": { _ in return (item: .staticButton(title: "exit"), action: .exitTouchbar) },
|
"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 {
|
struct BrightnessUpPress: KeyPress {
|
||||||
let keyCode: CGKeyCode = 113
|
let keyCode: CGKeyCode = 113
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
loadItems()
|
loadItems()
|
||||||
|
|
||||||
touchBar.delegate = self
|
touchBar.delegate = self
|
||||||
touchBar.defaultItemIdentifiers = Array(items.keys)
|
|
||||||
self.presentTouchBar()
|
self.presentTouchBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +58,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
|
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
|
||||||
let identifier = NSTouchBarItem.Identifier(identifierString)
|
let identifier = NSTouchBarItem.Identifier(identifierString)
|
||||||
items[identifier] = item
|
items[identifier] = item
|
||||||
|
touchBar.defaultItemIdentifiers += [identifier]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,9 +103,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch identifier {
|
switch identifier {
|
||||||
case .escButton:
|
|
||||||
return CustomButtonTouchBarItem(identifier: identifier, title: "esc", key: ESCKeyPress())
|
|
||||||
|
|
||||||
case .brightUp:
|
case .brightUp:
|
||||||
return CustomButtonTouchBarItem(identifier: identifier, title: "🔆", key: BrightnessUpPress())
|
return CustomButtonTouchBarItem(identifier: identifier, title: "🔆", key: BrightnessUpPress())
|
||||||
case .brightDown:
|
case .brightDown:
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
[
|
[
|
||||||
|
{ "type": "escape" },
|
||||||
{ "type": "brightnessUp" },
|
{ "type": "brightnessUp" },
|
||||||
{ "type": "exitTouchbar" },
|
{ "type": "exitTouchbar" },
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user