Hello Martin_fr.
I did what you suggested. As you say: ClipBoard.AsText pastes data which was copied to the clipboard before. PrimarySelection.AsText "pastes" data that is selected in another application. SecondarySelection.AsText does nothing (empty string). However, these have nothing to do with my problem. And actually when the problem occurs with the Lazarus editor, the same happens with the program: ClipBoard.AsText and PrimarySelection.AsText paste empty string; I verified this by using: Label1.Caption := IntToStr(Length(ClipBoard.AsText)).
I think Lazarus and the simple test program use the same code (libraries etc.), so they behave the same. Please note that, when this problem occurs (that is, when I cannot paste anything to Lazarus editor or in the test program), I can paste the data to another application, like LO Writer, Atom editor, Firefox, etc.
BTW; when this problem occurs, the context menu's Paste command or Ctrl+V on the test program's Memos works. But, the context menu's Paste command or Ctrl+V on Lazarus editor does not work.