forked from 1b-agent/opencadstudio-upstream
feat(web): copy/paste in text fields via the browser clipboard (#346)
iced's clipboard rides window_clipboard, which has no wasm backend — a focused text_input captured Ctrl+C/V on the web and did nothing. Ctrl+V (captured, wasm only): read the async browser clipboard (the keypress is a user gesture, so it's permitted) and replay the text as synthetic KeyboardEvents on the winit canvas — the only route into a focused text_input, since iced exposes no insert-text operation. Control characters are dropped and the length is capped. The MText and inline-TEXT editors keep their dedicated paste paths (no double feed), and an unfocused Ctrl+V still runs PASTECLIP. Ctrl+C (captured, wasm only): a widget operation pairs each text_input with its focus state (iced fires both callbacks back-to-back on the same widget) to collect the focused field's visible text, then writes it with navigator.clipboard.writeText. Whole-field text, not the selection — iced doesn't expose the selected range. Native behaviour is unchanged. Closes #346 Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
dd40e1f632
commit
5f08b77ebc
5 files changed
+147
No files matched your search
@@ -1265,6 +1265,17 @@ pub enum Message {
|
||||
OpenPathPicked(Option<(PathBuf, u64)>),
|
||||
/// A file was dragged from the desktop and dropped on the window (#344).
|
||||
FileDropped(PathBuf),
|
||||
/// Web only: Ctrl+V captured by a focused text field, whose iced-internal
|
||||
/// paste is inert there — read the async clipboard instead (#346).
|
||||
WebFieldPaste,
|
||||
/// Web only: clipboard text arrived for a focused field — replay it as
|
||||
/// synthetic keystrokes on the canvas.
|
||||
WebFieldPasteText(Option<String>),
|
||||
/// Web only: Ctrl+C captured by a focused text field — collect the
|
||||
/// focused input's text via a widget operation.
|
||||
WebFieldCopy,
|
||||
/// Web only: the focused field's text — write it to the clipboard.
|
||||
WebFieldCopyText(Option<String>),
|
||||
/// Pick from the one-shot snap override menu (Shift+RMB): only this snap
|
||||
/// applies to the next point pick, then the configuration restores (#337).
|
||||
SnapOverridePick(crate::snap::SnapType),
|
||||
|
||||
Reference in new issue
Block a user