Menu

Building a macOS selection toolbar with an explicit network boundary
📰

Building a macOS selection toolbar with an explicit network boundary

DEV Community: swift·Hu Qiyu·1 day ago
#Tpw1Ghjg
#devtoswift#devto#dev#selection#request
Long article (1065 words) — no AI summary yet.
Reading 0:00
15s threshold

The awkward case for a Mac selection toolbar is a footnote in a scan. In a browser, the user can drag across a sentence and an app may expose the string through Accessibility. In a scanned PDF, the same drag may yield a rectangle of pixels. You want the toolbar to feel familiar in both cases, while keeping that rectangle on the Mac and making the translation request a deliberate choice.

Lassoly’s selection toolbar and browser playground illustrate that interaction. Its Mac client builds on GPL-3.0 Easydict for selection capture and on-device OCR. The design below is a reference architecture for anyone building a similar tool. The Swift example shows the OCR step. Easydict source and license .

Let selection create a candidate

Check Accessibility permission during setup and explain the feature that needs it. Use the focused Accessibility element to ask for the selected string. When the application exposes a selection range and useful bounds, you can position the toolbar around it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.