PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Ctrl+V doesn't paste a picture while preparing a form
Marco Arnulfod5bde67e74f7
diff --git a/crates/ui-egui/src/content_ui.rs b/crates/ui-egui/src/content_ui.rsindex 44d4f08c4..54223a221 100644--- a/crates/ui-egui/src/content_ui.rs+++ b/crates/ui-egui/src/content_ui.rs@@ -858,11 +858,11 @@ impl crate::PdfCraftApp {/// ⌘V / Ctrl+V with a picture on the system clipboard (a screenshot, a picture copied in a/// browser) places it on the current page, as Add Image does.- /// Organize Pages keeps ⌘V for pages, and text fields for text.+ /// Organize Pages keeps ⌘V for pages, Prepare Form for fields, and text fields for text.pub(crate) fn paste_image_key(&mut self, i: usize, ctx: &egui::Context, pasted: bool) {let free = self.dialog.is_none() && !self.palette_open && !ctx.egui_wants_keyboard_input();let Some(view) = self.views.get(i) else { return };- if !pasted || !free || view.organize || view.forms.focus.is_some() {+ if !pasted || !free || view.organize || view.forms.focus.is_some() || self.is_preparing() {return;}let clip = match self.clipboard_override.clone() {diff --git a/crates/ui-egui/tests/content.rs b/crates/ui-egui/tests/content.rsindex c8f5270a1..6be7c4f56 100644--- a/crates/ui-egui/tests/content.rs+++ b/crates/ui-egui/tests/content.rs@@ -328,6 +328,15 @@ fn a_picture_on_the_clipboard_is_pasted_onto_the_page() {h.event(v(false, egui::Modifiers::COMMAND));h.run_steps(3);assert_eq!(images(&h), 2, "Organize Pages pastes pages");+ h.state_mut().views[0].organize = false;+ h.run_steps(3);+ // Prepare Form keeps ⌘V for form fields.+ assert!(h.state_mut().execute("form.prepare"));+ h.run_steps(3);+ assert!(h.state().is_preparing());+ h.event(v(false, egui::Modifiers::COMMAND));+ h.run_steps(3);+ assert_eq!(images(&h), 2, "Prepare Form pastes fields");}/// #125: text the standard fonts can't draw stays in the editor with a warning instead of being