19/06/2013 13:07, Hashini Senaratne:
I tested what you have given and that helped me to understand more. Today I
did more testing and realized that cur.pos() is not related with pixels and
this approach cannot be used as a generic solution.

Cur.pos() counts the characters. For example cur.pos()=5 when the cursor is in front of the 5th character. When using a development version of LyX, you can see the current paragraph and cursor position in the status bar.

If you want a position on screen, you need to use something like Cur.targetX(). If you look at Cursor.h, you will find several functions related to this targetX property. I am not sure what all of these things do.

[Side note: if during your research you find some function with a lacking/wrong documentation, fel free to submit a patch to improve it.]

Problems:
*I checked the cur.pos() values inside a tabular inset and it always remains
at 0.

If the cells are empty or cursor is at the start of the cell, this is normal. A cursor position is determined by a triplet:
* cell index
* paragraph index (pit)
* character index in the paragraph or the math inset (pos)

(I forgot the cell in my previous description, sorry!)

I think this also answers to your questions below, right?

Regards,
JMarc

*Also the position given in the screen, by a particular cur.pos() varies
according to the selected font size. Am I correct?
*As cur.pos() is just a increment that shows how far the cursor is from the
left most point of an inset; but not from the edge of the screen.

Is there any good attribute that we can use to compare; which can imply an
absolute position in the screen (may be in pixels)?

Thank you
Hashini





Reply via email to