Sha256: 8eee005bc2ce24cd76272c6b08fff77245383741f3d6c9545b529f4bf5f20cd0
Contents?: true
Size: 1.39 KB
Versions: 4
Compression:
Stored size: 1.39 KB
Contents
import AppKit import Carbon public final class HotKey { // MARK: - Types public typealias Handler = () -> Void // MARK: - Properties let identifier = UUID() public let keyCombo: KeyCombo public var keyDownHandler: Handler? public var keyUpHandler: Handler? public var isPaused = false { didSet { if isPaused { HotKeysController.unregister(self) } else { HotKeysController.register(self) } } } // MARK: - Initializers public init(keyCombo: KeyCombo, keyDownHandler: Handler? = nil, keyUpHandler: Handler? = nil) { self.keyCombo = keyCombo self.keyDownHandler = keyDownHandler self.keyUpHandler = keyUpHandler HotKeysController.register(self) } public convenience init(carbonKeyCode: UInt32, carbonModifiers: UInt32, keyDownHandler: Handler? = nil, keyUpHandler: Handler? = nil) { let keyCombo = KeyCombo(carbonKeyCode: carbonKeyCode, carbonModifiers: carbonModifiers) self.init(keyCombo: keyCombo, keyDownHandler: keyDownHandler, keyUpHandler: keyUpHandler) } public convenience init(key: Key, modifiers: NSEvent.ModifierFlags, keyDownHandler: Handler? = nil, keyUpHandler: Handler? = nil) { let keyCombo = KeyCombo(key: key, modifiers: modifiers) self.init(keyCombo: keyCombo, keyDownHandler: keyDownHandler, keyUpHandler: keyUpHandler) } deinit { HotKeysController.unregister(self) } }
Version data entries
4 entries across 2 versions & 2 rubygems