Skip to content

Commit

Permalink
TimecodeField: Now handles on-screen keyboard Return key on iPadOS
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Oct 11, 2024
1 parent eb9927e commit b65a1d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ extension TimecodeField {
#elseif os(iOS) || os(visionOS)
ZStack {
KeyboardInputView(
keyboardType: .decimalPad
keyboardType: .decimalPad // note that on iPadOS this also contains extended chars
) { keyEquivalent in
handleKeyPress(key: keyEquivalent)
_ = handleKeyPress(key: keyEquivalent)
}
.onKeyPress(phases: [.down, .repeat]) { keyPress in
// only handle hardware keyboard keys that aren't already handled by KeyboardInputView.
Expand Down
9 changes: 9 additions & 0 deletions Sources/TimecodeKitUI/Utilities/KeyboardInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ struct KeyboardInputView: UIViewRepresentable {
keyPressed(.delete)
}

// forward return key
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
keyPressed(.return)
return false
}

// TODO: could forward this in the future as well
// func textFieldShouldClear(_ textField: UITextField) -> Bool { }

override var hasText: Bool { true }
}
}
Expand Down

0 comments on commit b65a1d2

Please sign in to comment.