I have the following console program:
{$mode objfpc}{$H+}
uses Interfaces, // needs package LCL
clipbrd; // needs package LCLbase and unit Interfaces
begin
writeln('"', Clipboard.AsText, '"');
Clipboard.AsText:='Hello world';
writeln('"', Clipboard.AsText, '"');
end.
On Windows 7 (32 bit) it works as expected:
- it shows the text which was in the clipboard before the program was started
- then it shows "Hello World"
- after this the clipboard contains "Hello World"
On Linux (Ubuntu 18.04 64 bit) I have the following behaviour:
- it shows "" instead of the text which was in the clipboard before the program was started
- then it shows "Hello World"
- after this the contents of the clipboard have not been changed
An example:
- I select "some text" in the Lazarus text editor and copy it to the clipboard
- after starting my program it shows:
""
"Hello world"
- after this I paste the clipboard into the Lazarus text editor and get again "some text"
I use Lazarus 1.8.4 with FPC 3.0.4. What am I doing wrong?
I attached my little project. Thanks in advance.