A quick picker
A floating panel that opens on a shortcut from any app, with a search field over your items: emoji, symbols or snippets. You send the items; Ledge draws the panel, searches it as the person types, and puts the chosen item's text into the app they were in. Needs LedgeKit 0.19.0.
Sending the items
Add "picker" to surfaces, set kit.minAPI to 0.19.0, and send the picker once the add-on is ready. Send it again whenever the items change, as when Recents does:
AddOnSession.show(picker: Picker(title: "Emoji", placeholder: "Search emoji", style: .glyphs, sections: [
.init("recents", title: "Recents", symbol: "clock", items: recents),
.init("smileys", title: "Smileys & Emotion", symbol: "face.smiling", items: [
PickerItem("1f600", text: "😀", label: "grinning face", keywords: ["smile", "happy"]),
]),
]))
handlers.onPicked = { picked in
recents.insert(picked.id) // Ledge already put the text in
AddOnSession.show(picker: …)
}| Style | Shows |
|---|---|
.glyphs | A grid of large single characters, with the selected one's name underneath |
.rows | One row per item: its label, and its text in grey |
How search finds things
Every word the person types must start a word of an item's label or one of its keywords: “red hea” finds “red heart”, and “eart” finds nothing. Names that are the search, then names with it as a whole word, come first. PickerItem.matches is the same rule, so your tests can check what your words find.
Typing it in, or copying
Declare the insert-text capability for Ledge to type the chosen text into the app the person was in, as keystrokes, leaving their clipboard alone. It also needs Accessibility for Ledge. Without either, or if the person chose Copy, Ledge copies the text instead. The person picks the shortcut, where the panel opens and type-or-copy on your add-on's Settings page.
Limits
5,000 items in up to 24 sections, each item's text up to 1,000 characters, a label up to 100 and up to 12 keywords. Check it with ledgekit check: a {"picked": "1f600"} step picks an item as the person would.