@@ -98,20 +98,19 @@ fn main() {
9898 let clipboard = Clipboard :: get ( ) ;
9999
100100 // Implement button event handlers
101- let text_ctrl_copy = text_ctrl . clone ( ) ;
101+ // Widgets are Copy, so they can be used directly in closures
102102 copy_button. on_click ( move |_| {
103- let text = text_ctrl_copy . get_value ( ) ;
103+ let text = text_ctrl . get_value ( ) ;
104104 if clipboard. set_text ( & text) {
105105 println ! ( "Text copied to clipboard: {text}" ) ;
106106 } else {
107107 println ! ( "Failed to copy text to clipboard" ) ;
108108 }
109109 } ) ;
110110
111- let text_ctrl_paste = text_ctrl. clone ( ) ;
112111 paste_button. on_click ( move |_| {
113112 if let Some ( text) = clipboard. get_text ( ) {
114- text_ctrl_paste . set_value ( & text) ;
113+ text_ctrl . set_value ( & text) ;
115114 println ! ( "Text pasted from clipboard: {text}" ) ;
116115 } else {
117116 println ! ( "No text on clipboard or clipboard access failed" ) ;
@@ -143,8 +142,7 @@ fn main() {
143142 }
144143 } ) ;
145144
146- // For paste bitmap button - this should now work correctly with StaticBitmap's proper Clone
147- let static_bitmap_clone = static_bitmap. clone ( ) ;
145+ // For paste bitmap button - widgets are Copy
148146 paste_bitmap_button. on_click ( move |_| {
149147 // Check if bitmap format is supported
150148 if !clipboard. is_format_supported ( DataFormat :: BITMAP ) {
@@ -159,8 +157,7 @@ fn main() {
159157 if let Some ( _locker) = clipboard. locker ( ) {
160158 if clipboard. get_data ( & bitmap_data) {
161159 if let Some ( bitmap) = bitmap_data. get_bitmap ( ) {
162- // Now static_bitmap_clone is a proper StaticBitmap, not just a Window
163- static_bitmap_clone. set_bitmap ( & bitmap) ;
160+ static_bitmap. set_bitmap ( & bitmap) ;
164161 println ! ( "Bitmap pasted from clipboard" ) ;
165162 }
166163 } else {
@@ -199,42 +196,40 @@ fn main() {
199196 } ) ;
200197
201198 // Paste files from clipboard
202- let clipboard_paste = clipboard;
203- let file_text_ctrl_paste = file_text_ctrl. clone ( ) ;
204199 paste_file_button. on_click ( move |_| {
205- if let Some ( _locker) = clipboard_paste . locker ( ) {
200+ if let Some ( _locker) = clipboard . locker ( ) {
206201 // Check if file format is supported
207- if clipboard_paste . is_format_supported ( DataFormat :: FILENAME ) {
202+ if clipboard . is_format_supported ( DataFormat :: FILENAME ) {
208203 // Create a file data object to receive the data
209204 let file_data = FileDataObject :: new ( ) ;
210205
211206 // Try getting the data - this should now work with our fixed implementation
212- if clipboard_paste . get_data ( & file_data) {
207+ if clipboard . get_data ( & file_data) {
213208 // Get all files from the data object
214209 let files = file_data. get_files ( ) ;
215210
216211 if files. is_empty ( ) {
217212 println ! ( "No files on clipboard" ) ;
218- file_text_ctrl_paste . set_value ( "No files on clipboard" ) ;
213+ file_text_ctrl . set_value ( "No files on clipboard" ) ;
219214 } else {
220215 // Display the file paths in the text control
221216 let file_list = files. join ( "\n " ) ;
222217 println ! ( "Files pasted from clipboard:\n {file_list}" ) ;
223- file_text_ctrl_paste . set_value ( & file_list) ;
218+ file_text_ctrl . set_value ( & file_list) ;
224219 }
225220 } else {
226221 // Fallback to text for files
227- if let Some ( text) = clipboard_paste . get_text ( ) {
222+ if let Some ( text) = clipboard . get_text ( ) {
228223 println ! ( "Retrieved file path as text: {text}" ) ;
229- file_text_ctrl_paste . set_value ( & text) ;
224+ file_text_ctrl . set_value ( & text) ;
230225 } else {
231226 println ! ( "Failed to get files from clipboard" ) ;
232- file_text_ctrl_paste . set_value ( "Failed to get files from clipboard" ) ;
227+ file_text_ctrl . set_value ( "Failed to get files from clipboard" ) ;
233228 }
234229 }
235230 } else {
236231 println ! ( "No files on clipboard" ) ;
237- file_text_ctrl_paste . set_value ( "No files on clipboard" ) ;
232+ file_text_ctrl . set_value ( "No files on clipboard" ) ;
238233 }
239234 }
240235 } ) ;
0 commit comments