implement default entries for command tool. change add button to add/duplicate

This commit is contained in:
True Zhuanjia committed 2024-07-26 21:05:10 +08:00
1 parent 69056332d3
commit b53b0784aa
4 files changed
+46 -1

No files matched your search

+14
View File
@@ -230,6 +230,20 @@ import UIKit
loadCommands()
}
@objc static func presetDefaultCommands() {
let defaults = UserDefaults.standard
if defaults.data(forKey: "savedCommands") == nil { // save default entries if the data is empty.
let defaultCommands: [RemoteCommand] = [
RemoteCommand(keyboardCmdString: "CTRL+A", alias: "Select All"),
RemoteCommand(keyboardCmdString: "CTRL+C", alias: "Copy"),
RemoteCommand(keyboardCmdString: "CTRL+V", alias: "Paste")
]
let data = try? NSKeyedArchiver.archivedData(withRootObject: defaultCommands, requiringSecureCoding: false)
defaults.set(data, forKey: "savedCommands")
}
}
@objc public func createTestKeyMappings() -> [String: Int16] {
return CommandManager.keyMappings
}