Commit 025e8a2
authored
Fix NSScroller layout with Auto Layout constraints (#469)
Problem
When TerminalView is embedded using Auto Layout constraints (e.g., via SwiftUI's NSViewRepresentable with
translatesAutoresizingMaskIntoConstraints = false), the NSScroller appears mispositioned - stuck in the bottom-right
corner, scrolling horizontally instead of vertically.
Root Cause
The scroller was positioned using autoresizingMask (frame-based layout), which conflicts with constraint-based
layout. The frame calculations in getScrollerFrame() relied on bounds.maxX which may not be accurate before the
layout pass completes.
Solution
Use Auto Layout constraints to position the scroller:
Scroller is pinned to trailing/top/bottom anchors of the parent view
Width uses the system-provided NSScroller.scrollerWidth() value
Works correctly whether parent uses frame-based or constraint-based layout
Changes
setupScroller() now uses Auto Layout constraints instead of autoresizing masks
updateScrollerFrame() is now a no-op (constraints handle positioning)
Added scrollerWidth computed property for reliable width calculation
getScrollerFrame() preserved for backwards compatibility1 parent 08086f9 commit 025e8a2
1 file changed
+21
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
389 | 390 | | |
390 | 391 | | |
391 | 392 | | |
392 | 393 | | |
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
396 | | - | |
397 | 397 | | |
398 | | - | |
399 | | - | |
400 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
401 | 410 | | |
402 | | - | |
403 | 411 | | |
404 | 412 | | |
405 | 413 | | |
406 | | - | |
407 | 414 | | |
408 | 415 | | |
409 | 416 | | |
| |||
412 | 419 | | |
413 | 420 | | |
414 | 421 | | |
415 | | - | |
| 422 | + | |
416 | 423 | | |
417 | 424 | | |
418 | 425 | | |
| |||
431 | 438 | | |
432 | 439 | | |
433 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
434 | 445 | | |
435 | 446 | | |
436 | 447 | | |
437 | 448 | | |
438 | 449 | | |
439 | | - | |
| 450 | + | |
440 | 451 | | |
441 | | - | |
| 452 | + | |
442 | 453 | | |
443 | 454 | | |
444 | | - | |
| 455 | + | |
445 | 456 | | |
446 | 457 | | |
447 | 458 | | |
| |||
0 commit comments