From 297b6247ccc7600b1e2a0e2a10e044fdd3207679 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 16 Jan 2022 00:15:56 -0800 Subject: [PATCH] Show volume slider tooltip on the left side of the slider if it would otherwise run off the screen --- Window/VolumeSlider.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Window/VolumeSlider.m b/Window/VolumeSlider.m index b7d9f26aa..62bc8f292 100644 --- a/Window/VolumeSlider.m +++ b/Window/VolumeSlider.m @@ -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]; }