Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TPLTextEditorCaret2.GetObjectByMousePos(const mx, my: integer; ParentContainer:TPLTextEditorContainerList; const NoSetCaret:Boolean = False): TPLTextEditorBaseExtObject;
- var
- pt:TPoint;
- r:TRect;
- i:integer;
- BaseExt:TPLTextEditorBaseExtObject;
- begin
- pt:=Point(mx,my);
- result:=nil;
- if (ParentContainer = TextEditorSystem.RootContainer) and (not NoSetCaret) then
- Paint(False);
- for i:=0 to ParentContainer.DataList.Count-1 do begin
- BaseExt:=ParentContainer.DataList[i] as TPLTextEditorBaseExtObject;
- r.Left:=BaseExt.Left;
- r.Top:=BaseExt.Top;
- r.Right:=r.left+BaseExt.Width;
- r.Bottom:=r.Top+BaseExt.Height;
- if PtInRect(r, pt) then begin
- result:=BaseExt;
- if BaseExt is TPLTextEditorContainerList then begin
- result:=GetObjectByMousePos(mx,my,BaseExt as TPLTextEditorContainerList, NoSetCaret);
- if (Assigned(Result)) and (not NoSetCaret) then begin
- TextEditorSystem.CurrContainer:=(Result.Parent) as TPLTextEditorContainerList;
- TextEditorSystem.CurrObject:=Result;
- CaretTop:=Result.y;
- CaretLeft:=Result.x;
- end;
- end
- else begin
- if (not NoSetCaret) then begin
- TextEditorSystem.CurrContainer:=ParentContainer;
- TextEditorSystem.CurrObject:=Result;
- end;
- end;
- break;
- end;
- end; // for i
- if (ParentContainer = TextEditorSystem.RootContainer) and (not NoSetCaret) then
- Paint(True);
- end; // TPLTextEditorCaret2.GetObjectByMousePos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement