Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.51 KB | None | 0 0
  1. function TPLTextEditorCaret2.GetObjectByMousePos(const mx, my: integer; ParentContainer:TPLTextEditorContainerList; const NoSetCaret:Boolean = False): TPLTextEditorBaseExtObject;
  2. var
  3.   pt:TPoint;
  4.   r:TRect;
  5.   i:integer;
  6.   BaseExt:TPLTextEditorBaseExtObject;
  7. begin
  8.   pt:=Point(mx,my);
  9.   result:=nil;
  10.   if (ParentContainer = TextEditorSystem.RootContainer) and (not NoSetCaret) then
  11.     Paint(False);
  12.   for i:=0 to ParentContainer.DataList.Count-1 do begin
  13.     BaseExt:=ParentContainer.DataList[i] as TPLTextEditorBaseExtObject;
  14.     r.Left:=BaseExt.Left;
  15.     r.Top:=BaseExt.Top;
  16.     r.Right:=r.left+BaseExt.Width;
  17.     r.Bottom:=r.Top+BaseExt.Height;
  18.     if PtInRect(r, pt) then begin
  19.       result:=BaseExt;
  20.       if BaseExt is TPLTextEditorContainerList then begin
  21.         result:=GetObjectByMousePos(mx,my,BaseExt as TPLTextEditorContainerList, NoSetCaret);
  22.         if (Assigned(Result)) and (not NoSetCaret) then begin
  23.           TextEditorSystem.CurrContainer:=(Result.Parent) as TPLTextEditorContainerList;
  24.           TextEditorSystem.CurrObject:=Result;
  25.           CaretTop:=Result.y;
  26.           CaretLeft:=Result.x;
  27.         end;
  28.       end
  29.       else begin
  30.         if (not NoSetCaret) then begin
  31.           TextEditorSystem.CurrContainer:=ParentContainer;
  32.           TextEditorSystem.CurrObject:=Result;
  33.         end;
  34.       end;
  35.       break;
  36.     end;
  37.   end; // for i
  38.   if (ParentContainer = TextEditorSystem.RootContainer) and (not NoSetCaret) then
  39.     Paint(True);
  40. end; // TPLTextEditorCaret2.GetObjectByMousePos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement