Add customizable cursor style for TextField#53
Open
arcticleo wants to merge 1 commit intorensbreur:mainfrom
Open
Add customizable cursor style for TextField#53arcticleo wants to merge 1 commit intorensbreur:mainfrom
arcticleo wants to merge 1 commit intorensbreur:mainfrom
Conversation
With this proposed change, TextField gains the ability to customize its cursor appearance through a new environment value. The cursor can now be displayed as either an underline (the traditional style) or as an inverted block (similar to many terminal editors).
This enhancement is fully backwards compatible - the default cursor style remains as an underline, preserving existing behavior for all applications. Projects that want a block cursor can opt in using the new .textFieldCursorStyle(_:) view modifier.
Changes include:
- New TextFieldCursorStyle enum with .underline and .block cases
- New textFieldCursorStyle environment value (defaults to .underline)
- New .textFieldCursorStyle(_:) view modifier for easy customization
- Updated TextField rendering to respect the cursor style setting
Example usage:
TextField(placeholder: "Search...") { query in
// handle input
}
.textFieldCursorStyle(.block)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this proposed change, TextField gains the ability to customize its cursor appearance through a new environment value. The cursor can now be displayed as either an underline (default) or as an inverted block (similar to many terminal editors).
This enhancement is fully backwards compatible - the default cursor style remains as an underline, preserving existing behavior. Projects that want a block cursor can opt in using the new .textFieldCursorStyle(_:) view modifier.
Changes include:
Example usage: