Skip to content

Commit

Permalink
Fixed issue where ranged floating point values could stop responding …
Browse files Browse the repository at this point in the history
…to updates
  • Loading branch information
SteveBarnegren committed May 9, 2022
1 parent a06aa5c commit 567599c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion MirrorUI/MirrorUI/Types/NumericEntryBinder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ class NumericEntryBinder {
let textBinding: Binding<String>

private let _commit: () -> Void
private let _clear: () -> Void

convenience init<T>(state: Ref<[String: Any]>, ref: PropertyRef<T>) where T: StringRepresentable {

self.init(state: state,
get: { ref.value },
set: { ref.value = $0 },
set: { ref.value = $0 },
stateKey: "text")
}

Expand Down Expand Up @@ -49,11 +50,19 @@ class NumericEntryBinder {
editText = nil
}

_clear = {
editText = nil
}

textBinding = Binding(get: { editText ?? "" },
set: { editText = $0 })
}

func commit() {
_commit()
}

func clear() {
_clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fileprivate func makeRangedFloatingPointView<T: BinaryFloatingPoint>(context: Vi
let stack = VStack(alignment: .leading) {
Text(context.propertyName)
HStack {
Slider(value: numericBinding, in: range)
Slider(value: numericBinding, in: range, onEditingChanged: { _ in textBinder.clear() })
Button() {
editing = !editing
} label: {
Expand Down

0 comments on commit 567599c

Please sign in to comment.