Skip to content

Commit 7efdbde

Browse files
Fixed #7 - TGPDiscreteSlider sends UIControlEventValueChanged too often
1 parent 759e9b8 commit 7efdbde

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

TGPControls/TGPDiscreteSlider7.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,11 @@ - (void)touchUp:(NSSet *)touches {
457457

458458
- (void)moveThumbToTick:(unsigned int)tick {
459459
const unsigned int nonZeroIncrement = ((0 == self.incrementValue) ? 1 : self.incrementValue);
460-
_intValue = self.minimumValue + (tick * nonZeroIncrement);
461-
[self sendActionsForControlEvents];
460+
int intValue = self.minimumValue + (tick * nonZeroIncrement);
461+
if( intValue != _intValue) {
462+
_intValue = intValue;
463+
[self sendActionsForControlEvents];
464+
}
462465

463466
[self layoutThumb];
464467
[self setNeedsDisplay];
@@ -473,8 +476,11 @@ - (void)moveThumbTo:(CGFloat)abscisse duration:(CFTimeInterval)duration {
473476

474477
const unsigned int tick = [self pickTickFromSliderPosition:self.thumbAbscisse];
475478
const unsigned int nonZeroIncrement = ((0 == self.incrementValue) ? 1 : self.incrementValue);
476-
_intValue = self.minimumValue + (tick * nonZeroIncrement);
477-
[self sendActionsForControlEvents];
479+
int intValue = self.minimumValue + (tick * nonZeroIncrement);
480+
if( intValue != _intValue) {
481+
_intValue = intValue;
482+
[self sendActionsForControlEvents];
483+
}
478484

479485
[self setNeedsDisplay];
480486
}

0 commit comments

Comments
 (0)