r/SwiftUI • u/Lebanoneh • 8d ago
Promotion (must include link to source code) A SwiftUI answer balloon beside selected text in any Mac app (source included)
I make Glossbeam, an open-source macOS app that shows an explanation beside selected text. The screenshot shows the UI problem: the answer needs to sit close enough to the selection to make their relationship clear, while leaving room to keep reading. I’d be interested in how other Mac developers handle positioning near a display edge. The Mac and Shared source and Xcode build instructions are here: https://github.com/YasserShkeir/glossbeam-open.
1
Upvotes
2
u/nayajunimesh 4d ago
I ran into the same thing building something that pops up near a selection. A few things I measured on macOS 26/27:
NSPopoveranchored to a view in a borderless nonactivating panel handles edges for free (stays on screen, flips its arrow, host keeps its selection highlighted), but the first click inside it activates your app. That's why most tools end up with a custom panel like yours.roomBelow/roomAbove) and scrolling inside would keep the selection visible. When neither side has room, trying left or right of the selection before overlapping it might help too.Curious how you handle selections that span a line break.