Show volume slider tooltip on the left side of the slider if it would otherwise run off the screen

CQTexperiment
Christopher Snowhill 2022-01-16 00:15:56 -08:00
parent 6366769614
commit 297b6247cc
1 changed files with 7 additions and 1 deletions

View File

@ -65,7 +65,13 @@
// Show tooltip to the left of the Slider Knob
CGFloat height = self.knobThickness / 2.f + (self.bounds.size.height - self.knobThickness) * progress - 1;
[popover showRelativeToRect:NSMakeRect(width, height, 2, 2) ofView:self preferredEdge:NSRectEdgeMaxX];
NSWindow *window = self.window;
NSPoint screenPoint = [window convertPointToScreen:NSMakePoint(width + 1, height + 1)];
if (window.screen.frame.size.width < screenPoint.x + textView.bounds.size.width + 24) // wing it
[popover showRelativeToRect:NSMakeRect(1, height, 2, 2) ofView:self preferredEdge:NSRectEdgeMinX];
else
[popover showRelativeToRect:NSMakeRect(width, height, 2, 2) ofView:self preferredEdge:NSRectEdgeMaxX];
[self.window.parentWindow makeKeyWindow];
}