Instance Property
インスタンスプロパティ
projectedValue
A projection of the focus state value that returns a binding.
Discussion
議論
When focus is outside any view that is bound to this state, the wrapped value is nil
for optional-typed state or false
for Boolean state.
In the following example of a simple navigation sidebar, when the user presses the Filter Sidebar Contents button, focus moves to the sidebar’s filter text field. Conversely, if the user moves focus to the sidebar’s filter manually, then the value of isFiltering
automatically becomes true
, and the sidebar view updates.
struct Sidebar: View {
@State private var filterText = ""
@FocusState private var isFiltering: Bool
var body: some View {
VStack {
Button("Filter Sidebar Contents") {
isFiltering = true
}
TextField("Filter", text: $filterText)
.focused($isFiltering)
}
}
}
See Also
参照
Inspecting the Focus State
struct Binding
A property wrapper type that can read and write a value that indicates the current focus location.
var wrappedValue: Value
The current state value, taking into account whatever bindings might be in effect due to the current location of focus.