Recent

Author Topic: [SOLVED] TSynEdit - line number by point  (Read 6855 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
[SOLVED] TSynEdit - line number by point
« on: December 27, 2010, 03:37:36 am »
Hi,

I'm looking and looking and can't find function which get me line number at some TPoint. There is a lot of similar functions which uses TPoint but useless for my case.
I'm store some data on each line in Lines.Object property. I want read this data from line when user click on link (OnClickLink event which have X and Y params)

Regards
« Last Edit: December 27, 2010, 03:20:44 pm by Dibo »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: TSynEdit - line number by point
« Reply #1 on: December 27, 2010, 12:04:57 pm »
I'm looking and looking and can't find function which get me line number at some TPoint

I think you are doing something wrong with your "looking" ;-)
After 30 seconds I've found this

Code: Pascal  [Select][+][-]
  1. procedure TForm1.SynEdit1MouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);
  2. var RC:TPoint;
  3. begin
  4.  RC:=SynEdit1.PixelsToRowColumn(Point(X,Y));
  5.  Caption:=inttostr(RC.Y);
  6. end;
  7.  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9855
  • Debugger - SynEdit - and more
    • wiki
Re: TSynEdit - line number by point
« Reply #2 on: December 27, 2010, 12:29:23 pm »
IIRC the X,Y in the OnClickLink event are in lines (and columns) already, instead of pixels.

So that should be what you need.

Otherwhise
PixelsToRowColumn
PixelsToLogicalPos

They differ in how the return the x coordinate. either as char/grid or byte offset.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: TSynEdit - line number by point
« Reply #3 on: December 27, 2010, 03:20:10 pm »
Ehh I was blind. I was looking function with "line" in name. Thanks everyone.

 

TinyPortal © 2005-2018