NSScroller: clamp the value below zero as well as above one#495
Open
DTW-Thalion wants to merge 1 commit into
Open
NSScroller: clamp the value below zero as well as above one#495DTW-Thalion wants to merge 1 commit into
DTW-Thalion wants to merge 1 commit into
Conversation
e29e8cd to
92044a6
Compare
setFloatValue:knobProportion: clamped a value above 1 but not below 0: it sets _doubleValue to -1 as a redisplay marker before calling setDoubleValue:, whose no-change guard then mistook an input of -1 for the marker and skipped clamping. Clamp into [0,1] up front so a value of -1 reaches 0, as OS X does.
92044a6 to
eeae8a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-[NSScroller setFloatValue:knobProportion:]clamped a value above 1 butnot below 0. To force a redisplay it sets
_doubleValueto -1 beforecalling
-setFloatValue:(hence-setDoubleValue:), whose "no change"guard then mistook an input of -1 for that marker and returned early,
skipping its own clamping -- so
setFloatValue: -1left the value at -1.Clamp the value into [0,1] up front, so -1 reaches 0 as OS X does.
Verified on a macOS runner: setting -1 gives 0.
Adds a test for the value clamping.