Skip to content

Commit

Permalink
text selection example tuned
Browse files Browse the repository at this point in the history
  • Loading branch information
mecid committed Dec 11, 2024
1 parent b2385d3 commit 58c4cee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _posts/2024-12-03-text-field-enhancements-in-swiftui.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ struct ContentView: View {

var body: some View {
TextField("Very long text here", text: $text, selection: $selection)
.onChange(of: selection) {
if let selection = selection.take() {
if case let .selection(range) = selection.indices {
print(text[range])
}
}
}
}
}
```
Expand Down

0 comments on commit 58c4cee

Please sign in to comment.