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 -
This commit is contained in:
dmitry 2017-12-03 05:44:09 +00:00
parent 6273cd1d79
commit 6cb727545e

View File

@ -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;