0

Is it me or there is an bug with NSSlider when it is a subview of an NSPopover view?

Here's the code I use:

popover = NSPopover.new;
        popover.contentViewController = NSViewController.new;
        NSView *view = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, 100)];
        NSSlider *slider = [[NSSlider alloc] initWithFrame:NSMakeRect(20, 50, 150, 30)];
        slider.numberOfTickMarks = 6;
        [view addSubview:slider];
        popover.contentViewController.view = view;
[popover showRelativeToRect:self.frame ofView:self.view preferredEdge:NSMaxYEdge];

And this is how the NSSlider renders:

enter image description here

See how the tick marks are off-center. EDIT: the issue only appears in dark mode.

The same NSView (not an equivalent view, the very same NSView) set as the contentView in a NSWindow renders the slider properly like below (don't pay attention to the darker background):

enter image description here

Any idea what's going on? Whether I design the popover's view in IB or in code, this doesn't change anything. Nor does modifying the number of tick marks, layout contrains, or whatever I tried. This is on Monterey 13.2

And incidentally, any idea what the tickMarkPosition property of NSSlider is supposed to do? The doc seems clear, but on a slider that renders normally, the tick mark position is neither above nor below the slider, it's just centred (see second image). And changing the property has absolutely no effect on the tick mark position.

What am I missing?

jeanlain
  • 382
  • 1
  • 3
  • 13

0 Answers0