[Lazarus] Clipboard Data Goes Away

C Western l at c-m-w.me.uk
Thu Apr 1 18:51:35 CEST 2021


(You have definitely educated me)

I tried something similar on one of my own applications, and it doesn't 
work for me either. I suspect sometihing more elaborate is required, as 
I don't think the LCL does calls gtk_clipboard_set_text, even for text. 
Reading the documentation for gtk_clipboard_set_can_store suggests this 
should be called also, but a quick trial of this didn't work either.

Colin



On 01/04/2021 09:35, Anthony Walter via lazarus wrote:
> Here is a follow-up.
>
> I wrote a simple test using LCL Gtk2 and gtk_clipboard_store. This 
> test allows the clipboard data to persist after my program exited. 
> Button1 click sets the clipboard data. If Button2 clicked the data 
> will persist after the program exits. If Button2 is not clicked, the 
> data does not persist. Curiously, as the LCL Gtk2 currently stands, 
> gtk_clipboard_store() does not work. I suspect the LCL is not 
> using the same GdkAtom clipboard as returned by 
> gtk_clipboard_get(GDK_SELECTION_CLIPBOARD).
>
> uses
>   Gtk2, Gdk2;
>
> { TForm1 }
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
>   S: string;
> begin
>   S := Edit1.Text;
> gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), 
> PChar(S), Length(S))
> end;
>
> procedure TForm1.Button2Click(Sender: TObject);
> begin
> gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
> end;
>
> procedure TForm1.Button3Click(Sender: TObject);
> begin
>   Close;
> end;
>
>



More information about the lazarus mailing list