Text | TextContextMenu
TextContextMenu#
Description#
Component that draws the right-click menu on text fields using the system menu, like the rest of the desktop. Offers copy, cut, paste, and select all. It mounts only once per window, at the root, and listens on the document: screens and dialogs appear and disappear, and none of them has to remember anything. It draws nothing. The application passes it show (the function that opens the system menu) and optionally clipboard (if it does not use the default Rust commands).
Props#
show(function) — Opens the system menu and returns the chosen item. Receives(entries: TextMenuEntry[], event: MouseEvent)and returnsPromise<{ id: string } | null | undefined>. Required.clipboard(TextClipboard) — Clipboard interface withread()andwrite(text). Without it, uses the Rust commandsclipboard_read_textandclipboard_write_text. Default:undefined.copyLabel(string) — Text for the copy action. Default:undefined.cutLabel(string) — Text for the cut action. Default:undefined.pasteLabel(string) — Text for the paste action. Default:undefined.selectAllLabel(string) — Text for the select all action. Default:undefined.
Usage#
| |
Notes#
- The default clipboard goes through Rust (
clipboard_read_text/clipboard_write_text), because WebKitGTK does not implement theclipboard-readpermission andnavigator.clipboard.readText()returns nothing. - Texts come from the properties, the catalog (
textMenu.copy,textMenu.cut,textMenu.paste,textMenu.selectAll), or the English fallback. - Cut deletes the range that was copied, not the one selected when choosing.