mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 00:00:42 +02:00
SynEdit & Cocoa: improve the handling of Lookup Word when the cursor is not on the text
This commit is contained in:
parent
d0353d68d8
commit
c2d8e5ef9b
@ -178,15 +178,19 @@ procedure LazSynImeCocoa.LWRowColForScreenPoint(
|
||||
var
|
||||
localPoint: TPoint;
|
||||
logicalPoint: TPoint;
|
||||
pLine: pchar;
|
||||
lineText: String;
|
||||
begin
|
||||
localPoint:= FriendEdit.ScreenToClient( screenPoint );
|
||||
logicalPoint:= TSynEdit(FriendEdit).PixelsToLogicalPos( localPoint );
|
||||
params.row:= logicalPoint.Y;
|
||||
if params.row > 0 then
|
||||
params.row:= params.row - 1;
|
||||
pLine:= pchar( FriendEdit.Lines[params.row] );
|
||||
params.col:= UTF8Length( pLine, logicalPoint.x ) - 1;
|
||||
lineText:= FriendEdit.Lines[params.row];
|
||||
if logicalPoint.x <= lineText.length then begin
|
||||
params.col:= UTF8Length( pchar(lineText), logicalPoint.x ) - 1;
|
||||
end else begin
|
||||
params.col:= -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure LazSynImeCocoa.LWLineForRow( var params: TCocoaLWParameters );
|
||||
|
@ -460,12 +460,13 @@ var
|
||||
params: TCocoaLWParameters;
|
||||
lclPoint: TPoint;
|
||||
begin
|
||||
Result:= 0;
|
||||
Result:= NSNotFound;
|
||||
if NOT Assigned(self.lwHandler) then
|
||||
Exit;
|
||||
lclPoint:= ScreenPointFromNSToLCL( aPoint );
|
||||
self.lwHandler.LWRowColForScreenPoint( params, lclPoint );
|
||||
Result:= LWParamsToRange(params).location;
|
||||
if params.col >= 0 then
|
||||
Result:= LWParamsToRange(params).location;
|
||||
end;
|
||||
|
||||
function TCocoaFullControlEdit.validAttributesForMarkedText: NSArray;
|
||||
|
Loading…
Reference in New Issue
Block a user