From 58c39c14a5987f06f656bd33c78dec8077b5ca53 Mon Sep 17 00:00:00 2001 From: Michael Bach Date: Tue, 16 Jul 2024 16:15:57 +0200 Subject: [PATCH 1/3] Update CPSlider.j (fixing bindings for case 'only stop at tick marks' This fixes bindings to also work when 'only stop at tick marks' is selected; formerly the code would crash silently with `setObjectValue`. --- AppKit/CPSlider.j | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index b13d4d078..b7732c4dd 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -312,6 +312,9 @@ var AFFINITY = 5; if (!trackRect || CGRectIsEmpty(trackRect)) trackRect = bounds; + [self closestTickMarkValueToValue: [self doubleValue]]; // we only need the side effect … + _currentTickMarkSegment = _closestTickMarkIndex; // … when "Only stop on tick marks" selected + if (_isCircular) { var angle = 3 * PI_2 - (1.0 - [self doubleValue] - _minValue) / (_maxValue - _minValue) * PI2, From 00c3b2083b218cae084b0e8fafaf0f0181a650fe Mon Sep 17 00:00:00 2001 From: daboe01 Date: Tue, 16 Jul 2024 19:08:58 +0200 Subject: [PATCH 2/3] formatting --- AppKit/CPSlider.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index b7732c4dd..b89daa56d 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -312,7 +312,7 @@ var AFFINITY = 5; if (!trackRect || CGRectIsEmpty(trackRect)) trackRect = bounds; - [self closestTickMarkValueToValue: [self doubleValue]]; // we only need the side effect … + [self closestTickMarkValueToValue:[self doubleValue]]; // we only need the side effect … _currentTickMarkSegment = _closestTickMarkIndex; // … when "Only stop on tick marks" selected if (_isCircular) From 95e3ff33496cabfa61a863a09f98ef10e65eabae Mon Sep 17 00:00:00 2001 From: daboe01 Date: Tue, 16 Jul 2024 19:12:04 +0200 Subject: [PATCH 3/3] wrap fix in if (_allowsTickMarkValuesOnly) --- AppKit/CPSlider.j | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index b89daa56d..04c7f5ce8 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -312,8 +312,11 @@ var AFFINITY = 5; if (!trackRect || CGRectIsEmpty(trackRect)) trackRect = bounds; - [self closestTickMarkValueToValue:[self doubleValue]]; // we only need the side effect … - _currentTickMarkSegment = _closestTickMarkIndex; // … when "Only stop on tick marks" selected + if (_allowsTickMarkValuesOnly) + { + [self closestTickMarkValueToValue:[self doubleValue]]; // we only need the side effect … + _currentTickMarkSegment = _closestTickMarkIndex; + } if (_isCircular) {