* * *

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

mtanner

  • Full Member
  • ***
  • Posts: 204
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: 4629
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
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

ASerge

  • Sr. Member
  • ****
  • Posts: 452
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: 106
  • 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 1.6.4 r54278 FPC 3.0.2 x86_64-win64-win32/win64
Windows 10, 7.

Thaddy

  • Hero Member
  • *****
  • Posts: 4629
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.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Bazzao

  • Full Member
  • ***
  • Posts: 106
  • 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 1.6.4 r54278 FPC 3.0.2 x86_64-win64-win32/win64
Windows 10, 7.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus