From a3dc201d070f2fc5406d87a48afd087f4252c380 Mon Sep 17 00:00:00 2001 From: Chris Wynn <939050+wcwynn@users.noreply.github.com> Date: Thu, 1 May 2025 12:32:27 +0900 Subject: [PATCH] Added option for whether the system automatically enables the Return key - The default value for this property is false. If you set it to true, the keyboard disables the Return key when the text entry area contains no text. As soon as the user enters some text, the Return key is automatically enabled. https://developer.apple.com/documentation/uikit/uitextinputtraits/enablesreturnkeyautomatically --- Sources/ResponsiveTextField/ResponsiveTextField.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/ResponsiveTextField/ResponsiveTextField.swift b/Sources/ResponsiveTextField/ResponsiveTextField.swift index f2f8f23..110a73e 100644 --- a/Sources/ResponsiveTextField/ResponsiveTextField.swift +++ b/Sources/ResponsiveTextField/ResponsiveTextField.swift @@ -24,6 +24,9 @@ public struct ResponsiveTextField { /// some external state. let isSecure: Bool + /// Enables return key automatically. + let enablesReturnKeyAutomatically: Bool + /// Can be used to programatically control the text field's first responder state. /// /// When the binding's wrapped value is set, it will cause the text field to try and become or resign first responder status @@ -130,6 +133,7 @@ public struct ResponsiveTextField { placeholder: String?, text: Binding, isSecure: Bool = false, + enablesReturnKeyAutomatically: Bool = false, adjustsFontForContentSizeCategory: Bool = true, firstResponderDemand: Binding? = nil, configuration: Configuration = .empty, @@ -144,6 +148,7 @@ public struct ResponsiveTextField { self.text = text self.firstResponderDemand = firstResponderDemand self.isSecure = isSecure + self.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically self.configuration = configuration self.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory self.onFirstResponderStateChanged = onFirstResponderStateChanged @@ -329,6 +334,7 @@ extension ResponsiveTextField: UIViewRepresentable { textField.text = text.wrappedValue textField.isEnabled = isEnabled textField.isSecureTextEntry = isSecure + textField.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically textField.font = font textField.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory textField.textColor = textColor @@ -364,6 +370,7 @@ extension ResponsiveTextField: UIViewRepresentable { public func updateUIView(_ uiView: UITextField, context: Context) { uiView.isEnabled = isEnabled uiView.isSecureTextEntry = isSecure + uiView.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically uiView.returnKeyType = returnKeyType uiView.text = text.wrappedValue uiView.textColor = textColor