# Is there any text controls event in Swift ui

**URL:** <https://forums.kodeco.com/t/is-there-any-text-controls-event-in-swift-ui/85267>\
**Category:** SwiftUI by Tutorials\
**Created:** [October 17, 2019, 3:11am UTC](https://forums.kodeco.com/t/is-there-any-text-controls-event-in-swift-ui/85267 "2019-10-17T03:11:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yangwulong1978](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/yangwulong1978/32/102075_2.png) [@yangwulong1978](https://forums.kodeco.com/u/yangwulong1978)\
**Post date:** [October 17, 2019, 3:11am UTC](https://forums.kodeco.com/t/is-there-any-text-controls-event-in-swift-ui/85267/1 "2019-10-17T03:11:38Z")

</div>

as for textfield in storyboard, there are many event we can use,  
like  
Edit changed,  
Edit Did End… etc

I am wondering for text in swiftui, is there any similiar event, text control can trigger?

---

<div class="post-metadata">

**Author:** ![jeden](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jeden/32/110971_2.png) [@jeden](https://forums.kodeco.com/u/jeden)\
**Post date:** [October 21, 2019, 12:16pm UTC](https://forums.kodeco.com/t/is-there-any-text-controls-event-in-swift-ui/85267/2 "2019-10-21T12:16:39Z")

</div>

Most likely your TextField is bound to a state property, in that case you can use Swift’s property observers (`didChange`/`willChange`).

---

<div class="post-metadata">

**Author:** ![hastoro11](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hastoro11/32/81494_2.png) [@hastoro11](https://forums.kodeco.com/u/hastoro11)\
**Post date:** [October 21, 2019, 12:50pm UTC](https://forums.kodeco.com/t/is-there-any-text-controls-event-in-swift-ui/85267/3 "2019-10-21T12:50:14Z")

</div>

Yes there is: onEditingChanged and onCommit  
[https://developer.apple.com/documentation/swiftui/textfield/3338360-init](https://developer.apple.com/documentation/swiftui/textfield/3338360-init)

---

<div class="post-metadata">

**Author:** ![jeden](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jeden/32/110971_2.png) [@jeden](https://forums.kodeco.com/u/jeden)\
**Post date:** [October 21, 2019, 1:05pm UTC](https://forums.kodeco.com/t/is-there-any-text-controls-event-in-swift-ui/85267/4 "2019-10-21T13:05:14Z")

</div>

I think they are respectively for when the text field obtain or loses the focus, and when a commit action is done (such as tapping the return key on the soft keyboard). In both cases, these events happen before or after editing the text, but they are not called while editing.
