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 7131343
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ 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)
}
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 7131343

Please sign in to comment.