Skip to content

Commit

Permalink
Support empty modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Nov 22, 2017
1 parent df9793c commit 8916f17
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Sources/HotKey/KeyCombo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public struct KeyCombo {
}

set {
guard let key = newValue else { return }
carbonKeyCode = key.carbonKeyCode
carbonKeyCode = newValue?.carbonKeyCode ?? 0
}
}

Expand All @@ -37,18 +36,18 @@ public struct KeyCombo {
}

public var isValid: Bool {
return carbonKeyCode >= 0 && carbonModifiers > 0
return carbonKeyCode >= 0
}


// MARK: - Initializers

public init(carbonKeyCode: UInt32, carbonModifiers: UInt32) {
public init(carbonKeyCode: UInt32, carbonModifiers: UInt32 = 0) {
self.carbonKeyCode = carbonKeyCode
self.carbonModifiers = carbonModifiers
}

public init(key: Key, modifiers: NSEvent.ModifierFlags) {
public init(key: Key, modifiers: NSEvent.ModifierFlags = []) {
self.carbonKeyCode = key.carbonKeyCode
self.carbonModifiers = modifiers.carbonFlags
}
Expand Down

0 comments on commit 8916f17

Please sign in to comment.