Skip to content

SecureField#490

Open
kaascevich wants to merge 13 commits intomoreSwift:mainfrom
kaascevich:secure-field
Open

SecureField#490
kaascevich wants to merge 13 commits intomoreSwift:mainfrom
kaascevich:secure-field

Conversation

@kaascevich
Copy link
Contributor

@kaascevich kaascevich commented Mar 15, 2026

This PR adds SecureField, which is simply TextField but everything shows up as a dot. Implemented and working on all backends. (There is a quirk on WinUIBackend where the field doesn’t show up until the first rerender -- I have absolutely no idea where this bug could be coming from and so I’m saving it for Later™.)

Resolves #247.

@stackotter
Copy link
Collaborator

This might help fix the WinUI issue;

} else if let textField = widget as? WinUI.TextBox, textField.padding == noPadding {

(it’s what I did to fix a basically identical issue with TextField widgets)

@kaascevich
Copy link
Contributor Author

That works, thanks! (I just replaced TextBox with TextBoxProtocol)

@stackotter
Copy link
Collaborator

Looks like you need to add default implementations to AppBackend to satisfy the CI (and implement DummyBackend support)

Copy link
Collaborator

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed the backend code because it'll probably change as a result of this set of comments; just focussed on the common SCUI implementation.

///
/// - Returns: A text field.
func createTextField() -> Widget
func createTextField(secure: Bool) -> Widget
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that many backends have to use separate underlying widget types, and the API is used to back a different SwiftCrossUI view, I believe that it'd be best to make separate createSecureTextField and updateSecureTextField methods. Backends such as GtkBackend that don't need specical secure handling can then use just defer to their existing createTextField and updateTextField implementations.

}

/// A control that displays an editable text interface.
public struct TextField: TextFieldProtocol {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this type to its own file

}

/// A control that displays an editable text interface with hidden input.
public struct SecureField: TextFieldProtocol {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this type to its own file as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request - SecureField

2 participants