View Issue Details

IDProjectCategoryView StatusLast Update
0035984LazarusWidgetsetpublic2019-08-20 17:07
ReporterZoë Peterson Assigned ToDmitry Boyarintsev  
Status resolvedResolutionfixed 
Product Version2.0.4 
Summary0035984: Clipboard.SetAsText includes an extra #0 character
DescriptionWhen using Clipboard.AsText to copy text to the Cocoa clipboard, an extra invalid #0 character is inserted at the end. You can see the behavior by selecting and copying text in SynEdit then pasting in Xcode. If you paste in the middle of a comment it will break syntax highlighting, and pressing delete will seem to pause for one delete keystroke since it's deleting the invisible #0 character. Copying/pasting within an LCL application won't show the issue since GetAsText silently strips a trailing #0 if one exists.

Patch attached that disables the (LCL) behavior for the Cocoa widgetset
TagsNo tags attached.
Fixed in Revision61731
Attached Files


related to 0021453 resolvedMartin Friebe Remove trailing zero when copying to clipboard (gtk2) 


Zoë Peterson

2019-08-19 22:43


cocoa-clipboard.patch (1,216 bytes)   
--- a/lcl/interfaces/cocoa/
+++ b/lcl/interfaces/cocoa/
@@ -254,6 +254,12 @@ begin
+function TCocoaWidgetSet.ClipboardFormatNeedsNullByte(
+  const AFormat: TPredefinedClipboardFormat): Boolean;
+  Result := False
 function TCocoaWidgetSet.CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;
   Result := LCLType.Error;
diff --git a/lcl/interfaces/cocoa/ b/lcl/interfaces/cocoa/
index 46b141bb6a..f16cac1ba9 100644
--- a/lcl/interfaces/cocoa/
+++ b/lcl/interfaces/cocoa/
@@ -42,6 +42,7 @@ function ClipboardGetOwnerShip(ClipboardType: TClipboardType;
   OnRequestProc: TClipboardRequestEvent;  FormatCount: integer;
   Formats: PClipboardFormat): boolean; override;
 function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; override;
+function ClipboardFormatNeedsNullByte(const AFormat: TPredefinedClipboardFormat): Boolean; override;
 function CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;  override;
 function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
cocoa-clipboard.patch (1,216 bytes)   

Dmitry Boyarintsev

2019-08-20 17:07

developer   ~0117745

thanks for the patch. applied.
please test and close if ok

Issue History

Date Modified Username Field Change
2019-08-19 22:43 Zoë Peterson New Issue
2019-08-19 22:43 Zoë Peterson File Added: cocoa-clipboard.patch
2019-08-20 17:04 Dmitry Boyarintsev Relationship added related to 0021453
2019-08-20 17:07 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-08-20 17:07 Dmitry Boyarintsev Status new => resolved
2019-08-20 17:07 Dmitry Boyarintsev Resolution open => fixed
2019-08-20 17:07 Dmitry Boyarintsev Fixed in Revision => 61731
2019-08-20 17:07 Dmitry Boyarintsev LazTarget => -
2019-08-20 17:07 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-08-20 17:07 Dmitry Boyarintsev Note Added: 0117745