From 6cb727545e74b0b15e9ac72783eedcc6a1f060a6 Mon Sep 17 00:00:00 2001 From: dmitry Date: Sun, 3 Dec 2017 05:44:09 +0000 Subject: [PATCH] cocoa: implemenating a storage of stringValue for a custom control (in order to keep text of the control for TPanels). related to #30801 git-svn-id: trunk@56589 - --- lcl/interfaces/cocoa/cocoaprivate.pp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lcl/interfaces/cocoa/cocoaprivate.pp b/lcl/interfaces/cocoa/cocoaprivate.pp index fd58bb426f..06478894b7 100644 --- a/lcl/interfaces/cocoa/cocoaprivate.pp +++ b/lcl/interfaces/cocoa/cocoaprivate.pp @@ -396,8 +396,11 @@ type { TCocoaCustomControl } TCocoaCustomControl = objcclass(NSControl) + private + fstr : NSString; public callback: ICommonCallback; + procedure dealloc; override; function acceptsFirstResponder: Boolean; override; function becomeFirstResponder: Boolean; override; function resignFirstResponder: Boolean; override; @@ -425,6 +428,9 @@ type // other procedure resetCursorRects; override; function lclIsHandle: Boolean; override; + // value + procedure setStringValue(avalue: NSString); override; + function stringValue: NSString; override; end; { TCocoaWindowContent } @@ -2138,6 +2144,27 @@ begin Result := True; end; +procedure TCocoaCustomControl.setStringValue(avalue: NSString); +begin + if Assigned(fstr) then fstr.release; + if ASsigned(avalue) then + fstr:=avalue.copyWithZone(nil) + else + fstr:=nil; + inherited setStringValue(avalue); +end; + +function TCocoaCustomControl.stringValue: NSString; +begin + Result:=fstr; +end; + +procedure TCocoaCustomControl.dealloc; +begin + if Assigned(fstr) then fstr.release; + inherited dealloc; +end; + function TCocoaCustomControl.acceptsFirstResponder: Boolean; begin Result := True;