File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,15 @@ public struct KeyContainer<Content: View>: View {
3232
3333 func rect( rect: CGRect ) -> some View {
3434 content ( pitch, model. touchedPitches. contains ( pitch) || model. externallyActivatedPitches. contains ( pitch) )
35- . contentShape ( Rectangle ( ) ) // Added to improve tap/click reliability
35+ . contentShape ( Rectangle ( ) )
3636 . gesture (
3737 TapGesture ( ) . onEnded { _ in
38- if model. externallyActivatedPitches. contains ( pitch) {
39- model. externallyActivatedPitches. remove ( pitch)
40- } else {
41- model. externallyActivatedPitches. add ( pitch)
38+ if model. latching {
39+ if model. externallyActivatedPitches. contains ( pitch) {
40+ model. externallyActivatedPitches. remove ( pitch)
41+ } else {
42+ model. externallyActivatedPitches. add ( pitch)
43+ }
4244 }
4345 }
4446 )
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ public struct Keyboard<Content>: View where Content: View {
8181 } . onAppear {
8282 model. noteOn = noteOn
8383 model. noteOff = noteOff
84+ model. latching = latching
8485 }
8586 }
8687}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ public class KeyboardModel: ObservableObject {
99 var noteOn : ( Pitch , CGPoint ) -> Void = { _, _ in }
1010 var noteOff : ( Pitch ) -> Void = { _ in }
1111 var normalizedPoints = Array ( repeating: CGPoint . zero, count: 128 )
12+ var latching : Bool = false
1213
1314 var touchLocations : [ CGPoint ] = [ ] {
1415 didSet {
You can’t perform that action at this time.
0 commit comments