Le 17/06/2013 19:12, Hashini Senaratne a écrit :
Hello All,
When I replace the line;
RowPainter rp(pi, *text_, pit, row, bidi, x, y);
in TextMetrics.cpp with following few lines:
int inc_x=x;
if(cur.pos()>0)
inc_x-=100;
RowPainter rp(pi, *text_, pit, row, bidi, inc_x, y);
Is it because that every row sees their cursor position as the active cursor
position? For a single row movement do I need to check that the cursor lies
on the required row (within the if statement)?
If so, how can is there a straight forward way to check whether the cursor
lies in a particular row? I searched for it in Cursor.cpp and could not find
a public method that helps this.
Hello Hashini,
You have to check that you are in the correct paragraph. pos is the
position in the paragraph. The index of the paragraph is "pit" (the same
that is passed to RowPainter constructor). Thus the test should be
if (cur.pos() >0 && cur.pit() == pit)
This will however not be enough for nested insets, since the cursor
could be at the pos character of the paragraph pit, but in _another_
inset. Therefore I would recommend something like
if (cur.inTexted() && cur.text() == text_ && cur.pos() >0 &&
cur.pit() == pit)
What the extra checks do are
* test that we are in a text inset (not maths)
* check whether the Text object is the same as the underlying Text of
TextMetrics (this ensures that we are in the right inset).
There may be a shorter test, but I cannot find it right now.
Hope this helps.
JMarc