Cocoa: add util NSControlMoveCaretToTheEnd()

This commit is contained in:
rich2014 2024-09-19 20:48:16 +08:00
parent b33ed34bed
commit 7010173b69

View File

@ -84,6 +84,7 @@ function GetNSText(text: NSText): string; inline;
procedure SetNSControlValue(c: NSControl; const S: String); inline;
function GetNSControlValue(c: NSControl): String; inline;
procedure NSControlMoveCaretToTheEnd(c: NSControl);
procedure ColorToRGBFloat(cl: TColorRef; var r,g,b: Single); inline;
function RGBToColorFloat(r,g,b: Single): TColorRef; inline;
@ -1062,6 +1063,17 @@ begin
Result := '';
end;
procedure NSControlMoveCaretToTheEnd(c: NSControl);
var
range: NSRange;
begin
if c.currentEditor <> nil then begin
range.location:= NSUIntegerMax;
range.length:= 0;
c.currentEditor.setSelectedRange( range );
end;
end;
{ NSLCLDebugExtension }
function NSLCLDebugExtension.lclClassName: shortstring;