How Paste Switch solved macOS input position tracking for clipboard overlays
Developer of Paste Switch, a macOS clipboard utility, faced a complex challenge in positioning a small overlay near the active text cursor when cycling through clipboard items. macOS does not expose a uniform accessibility interface across native apps, browsers, and Electron apps, meaning the same caret-position API can return exact coordinates, element-level frames, or nothing at all. The solution uses Apple's Accessibility API starting with AXSelectedTextRange and AXBoundsForRange, but falls back to element frame data when precise caret bounds are unavailable. A decision tree with detailed logging distinguishes between exact caret positions and approximate input-box anchors, preventing the overlay from appearing on the wrong monitor or at a stale location. The approach highlights how seemingly minor UI details in utility apps can require significant engineering to handle edge cases across different application surfaces.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in