mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 22:20:17 +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
|
var
|
||||||
localPoint: TPoint;
|
localPoint: TPoint;
|
||||||
logicalPoint: TPoint;
|
logicalPoint: TPoint;
|
||||||
pLine: pchar;
|
lineText: String;
|
||||||
begin
|
begin
|
||||||
localPoint:= FriendEdit.ScreenToClient( screenPoint );
|
localPoint:= FriendEdit.ScreenToClient( screenPoint );
|
||||||
logicalPoint:= TSynEdit(FriendEdit).PixelsToLogicalPos( localPoint );
|
logicalPoint:= TSynEdit(FriendEdit).PixelsToLogicalPos( localPoint );
|
||||||
params.row:= logicalPoint.Y;
|
params.row:= logicalPoint.Y;
|
||||||
if params.row > 0 then
|
if params.row > 0 then
|
||||||
params.row:= params.row - 1;
|
params.row:= params.row - 1;
|
||||||
pLine:= pchar( FriendEdit.Lines[params.row] );
|
lineText:= FriendEdit.Lines[params.row];
|
||||||
params.col:= UTF8Length( pLine, logicalPoint.x ) - 1;
|
if logicalPoint.x <= lineText.length then begin
|
||||||
|
params.col:= UTF8Length( pchar(lineText), logicalPoint.x ) - 1;
|
||||||
|
end else begin
|
||||||
|
params.col:= -1;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LazSynImeCocoa.LWLineForRow( var params: TCocoaLWParameters );
|
procedure LazSynImeCocoa.LWLineForRow( var params: TCocoaLWParameters );
|
||||||
|
@ -460,12 +460,13 @@ var
|
|||||||
params: TCocoaLWParameters;
|
params: TCocoaLWParameters;
|
||||||
lclPoint: TPoint;
|
lclPoint: TPoint;
|
||||||
begin
|
begin
|
||||||
Result:= 0;
|
Result:= NSNotFound;
|
||||||
if NOT Assigned(self.lwHandler) then
|
if NOT Assigned(self.lwHandler) then
|
||||||
Exit;
|
Exit;
|
||||||
lclPoint:= ScreenPointFromNSToLCL( aPoint );
|
lclPoint:= ScreenPointFromNSToLCL( aPoint );
|
||||||
self.lwHandler.LWRowColForScreenPoint( params, lclPoint );
|
self.lwHandler.LWRowColForScreenPoint( params, lclPoint );
|
||||||
Result:= LWParamsToRange(params).location;
|
if params.col >= 0 then
|
||||||
|
Result:= LWParamsToRange(params).location;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaFullControlEdit.validAttributesForMarkedText: NSArray;
|
function TCocoaFullControlEdit.validAttributesForMarkedText: NSArray;
|
||||||
|
Loading…
Reference in New Issue
Block a user