Clicking mouse indicates wrong line

SyntaxEditor for WPF Forum

Posted 3 months ago by Antonio Sanchez
Version: 22.1.1
Avatar

I need to know the line number where the user clicks the mouse. If the whole content can be visible, it works fine. But if it is larger (so there is a vertical Scrollbar) the line number is wrong.

Say I have 90 lines. I scroll to the bottom of the document. I see last lines. For example lines 81 to 90. If I click third visible line, I expect the information to be 83. What I get is:

SyntaxEditor.ActiveView.CurrentSnapshot.Lines => returns 90

SyntaxEditor.ActiveView.CurrentSnapshotLine.Index +1 => returns 3 (Index start in 0, so I know I have to add 1).

SyntaxEditor.ActiveView.CurrentSnapshotLine.Text => returns the content of line 3 (not of line 83 which is where user clicked).

All properties descendant from the ActiveView related to the line indicate that I am in line 3 instead of 83.

I do not mind doing some computation: if I can know that above the screen there are 80 lines and the user clicked the third visible line, it would be fine. I can add that 80 previous lines + 3 to know the user is in line 83.

Comments (1)

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Can you tell us exactly how to reproduct this in one of our samples, step by step, with any code added or breakpoints needed?  I did a test here of opening a large file, scrolling down, clicking in the text area to move the caret and then checking the CurrentSnapshotLine and it was properly in sync with the line I had clicked.

Keep in mind that the CurrentSnapshotLine is based on where the primary caret is located.  It will return the snapshot line that currently contains the caret.  If you clicked somewhere in a way that didn't move the caret, that might be why the property is not returning what you expect.


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.