Skip to content

NSScroller: clamp the value below zero as well as above one#495

Open
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/nsscroller-clamp-floatvalue
Open

NSScroller: clamp the value below zero as well as above one#495
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/nsscroller-clamp-floatvalue

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

-[NSScroller setFloatValue:knobProportion:] clamped a value above 1 but
not below 0. To force a redisplay it sets _doubleValue to -1 before
calling -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: -1 left 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.

@DTW-Thalion DTW-Thalion requested a review from fredkiefer as a code owner July 12, 2026 18:25
@DTW-Thalion DTW-Thalion force-pushed the fix/nsscroller-clamp-floatvalue branch from e29e8cd to 92044a6 Compare July 12, 2026 20:41
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.
@DTW-Thalion DTW-Thalion force-pushed the fix/nsscroller-clamp-floatvalue branch from 92044a6 to eeae8a7 Compare July 12, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant