Recent

Author Topic: CopyToClipboard not working for TEdit  (Read 3695 times)

mtanner

  • Sr. Member
  • ****
  • Posts: 287
CopyToClipboard not working for TEdit
« on: August 15, 2017, 10:17:22 am »
I have a TEdit with some text in that I need to copy to the clipboard.

With MyEdit do begin
  SelectAll;
  CopyToClipBoard;
end;

should work, it does in Delphi, but it does not.

Clipboard.AsText:=MyEdit.Text;

does work.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: CopyToClipboard not working for TEdit
« Reply #1 on: August 15, 2017, 11:43:07 am »
It does not work the first time indeed, it works the second time, though. That's a bug. Tested arm-linux Raspbian-jessie
Specialize a type, not a var.

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: CopyToClipboard not working for TEdit
« Reply #2 on: August 15, 2017, 08:23:42 pm »
It does not work the first time indeed, it works the second time, though. That's a bug. Tested arm-linux Raspbian-jessie
Under Windows works as expected.

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: CopyToClipboard not working for TEdit
« Reply #3 on: August 19, 2017, 01:08:21 pm »
I had the same issue with a TMemo.  >:(

I tried Application.ProcessMessages while assembling the data in the Memo.

I tried CopyToClipboard twice in a row. Even a few more times in a row, in case I had to bash Memo into submission.

No luck, even with the violent coding.  >:D

Then I discovered the solution above, ("Clipboard.AsText:=MyEdit.Text;") and that worked.

B

Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: CopyToClipboard not working for TEdit
« Reply #4 on: August 19, 2017, 01:39:35 pm »
It does not work the first time indeed, it works the second time, though. That's a bug. Tested arm-linux Raspbian-jessie
Under Windows works as expected.

Yes I know, but not under linux -gtk 2.
Specialize a type, not a var.

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: CopyToClipboard not working for TEdit
« Reply #5 on: August 19, 2017, 01:43:39 pm »
Now here is some evidence ...

Originally I had the Memo as a variable under Private (Form), and the CopyToClipboard did not work.

Thinking it was my coding, I added a Memo to the form and duplicated the code so the new Memo would receive data (it is used for concatenation).

CopyToClipboard then worked.  ;D

So I deleted the original variable, hid the new Memo, and placed it down the Z order.

CopyToClipboard then failed.  >:(

At that point I found the solution in this thread.

After posting my previous reply, I commented out the solution, I made the Memo visible again, and the CopyToClipboard then worked. Weird.

Violent coding does not work and neither does hiding things.  :-\

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

dvhx

  • New Member
  • *
  • Posts: 17
Re: CopyToClipboard not working for TEdit
« Reply #6 on: November 27, 2023, 06:22:57 pm »
Nothing works for me, not even nuclear option:

Code: Pascal  [Select][+][-]
  1.   with TStringList.Create do
  2.   try
  3.     Text := 'alpha';
  4.     SaveToFile('alpha.txt');
  5.     Text := 'beta';
  6.     SaveToFile('beta.txt');
  7.   finally
  8.     Free;
  9.   end;
  10.   with TProcess.Create(nil) do
  11.   try
  12.     CommandLine:= 'xclip -i -selection primary alpha.txt';
  13.     Options:= [poWaitOnExit];
  14.     Execute;
  15.     CommandLine:= 'xclip -i -selection secondary beta.txt';
  16.     Options:= [poWaitOnExit];
  17.     Execute;
  18.   finally
  19.     Free;
  20.   end;
  21.   sleep(1000);
  22.  

Clipboard in linux is beyond broken. Don't use it.
« Last Edit: November 28, 2023, 08:42:36 am by dvhx »

 

TinyPortal © 2005-2018