mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Rewrote presets parsing. Instead of parsing presets in a separate file using bunch of huge enums it is now parsed inside each object. To implement a new class: 1. Derive your class from CustomTouchBarItem (for static) or CustomButtonTouchBarItem (for buttons) 2. Override class var typeIdentifier with your object identificator 3. Override init(from decoder: Decoder) and read all custom json params you need 4. Don't forget to call super.init(identifier: CustomTouchBarItem.createIdentifier(type)) in the init() function 5. Add your new class to BarItemDefinition.types in ItemParsing.swift Good example is PomodoroBarItem If you want to inherid from some other NS class (NSSlider or NSPopoverTouchBarItem or other) then look into GroupBarItem and BrightnessViewController
28 lines
634 B
Swift
28 lines
634 B
Swift
//
|
|
// EscapeBarItem.swift
|
|
// MTMR
|
|
//
|
|
// Created by Fedor Zaitsev on 4/27/20.
|
|
// Copyright © 2020 Anton Palgunov. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class EscapeBarItem: CustomButtonTouchBarItem {
|
|
override class var typeIdentifier: String {
|
|
return "escape"
|
|
}
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
try super.init(from: decoder)
|
|
|
|
self.title = "escape"
|
|
self.setTapAction(EventAction().setKeyPressClosure(keycode: 53))
|
|
self.align = .left
|
|
}
|
|
|
|
required init?(coder _: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|