* * *

Author Topic: Copy-to-clipboard, text clears after exiting my app  (Read 493 times)

Alextp

  • Sr. Member
  • ****
  • Posts: 375
    • UVViewSoft
Copy-to-clipboard, text clears after exiting my app
« on: March 07, 2017, 05:08:34 pm »
CudaText app (LCL, Linux gtk2)
I copy text as

Clipboard.AsText:= 'dddddddddddd';

after my app exits, other apps don't see this text. Clipboard empty. Why?

Bart

  • Hero Member
  • *****
  • Posts: 2599
    • Bart en Mariska's Webstek
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #1 on: March 07, 2017, 07:10:59 pm »
AFAIK this is standard *nix behaviour.

Bart

Alextp

  • Sr. Member
  • ****
  • Posts: 375
    • UVViewSoft
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #2 on: March 07, 2017, 08:34:54 pm »
GEdit does it ok: after exiting, it's clipboard text can be pasted.
How to do it?

Abelisto

  • Jr. Member
  • **
  • Posts: 58
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #3 on: March 07, 2017, 10:35:24 pm »
Code: Pascal  [Select]
  1. unit fix_gtk_clip;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.     gtk2, gdk2, Clipbrd;
  9.  
  10. implementation
  11.  
  12. var
  13.     c: PGtkClipboard;
  14.     t: string;
  15.  
  16. finalization
  17.     c := gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
  18.     t := Clipboard.AsText;
  19.     gtk_clipboard_set_text(c, PChar(t), Length(t));
  20.     gtk_clipboard_store(c);
  21. end.
Add this unit somewhere. It is dirty solution but it works for me.
OS: Linux Mint + MATE, Compiler: FPC trunk (yes, I am risky!), IDE: Lazarus trunk

Alextp

  • Sr. Member
  • ****
  • Posts: 375
    • UVViewSoft

Abelisto

  • Jr. Member
  • **
  • Posts: 58
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #5 on: March 08, 2017, 09:25:07 am »
There is another topic about the problem with some useful links: http://forum.lazarus.freepascal.org/index.php/topic,35244
OS: Linux Mint + MATE, Compiler: FPC trunk (yes, I am risky!), IDE: Lazarus trunk

 

Recent

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