DirectEntry cursor position bug?

Using Panda3D 1.5.2 on Ubuntu 8.10 there seems to be a bug in DirectEntry with the position that cursor is drawn at.

  • Put the cursor at the start of the first line (position 0), and it appears to be at the end of the first line, you see the blinking cursor drawn at the end of the line, but it acts as if it’s at the start of the line. If you press delete it will delete the first character on the first line, if you type a letter it will appear at the start of the line, if you press right arrow the cursor will move to before the second character on the line, etc.

  • Put the cursor at the start of the second line, again it appears to be at the end of the first line.

  • Put it at the start of the third line, it appears to be at the end of the second line.

  • Start of the fourth line, it appears to be at the end of the third line.

  • And so on.

When you’re dealing with the second, third, fourth etc. line this makes a certain amount of sense. The cursor is drawn at the end of the previous character rather than at the start of the next character, and the ‘lines’ are not separated by newline characters, they’re just word-wrapped, DirectEntry behaves as if it’s all one line.

But in the case of the first line, it really doesn’t make sense, the cursor needs to be drawn at the start of the line, not the end.

yeah, my testers also noticed this bug. It looks like it only happens when you manually set the cruiser position at some point or alter the internal text.

Hmm, no it seems to happen all the time. It even occurs in the DirectEntry example in the manual. If you move the cursor to before the first character in the DirectEntry, it is drawn after the last character of the first line instead.

Here’s a movie showing the bug: homepages.inf.ed.ac.uk/s0094060/directentry.ogg

Notice that at the start, the cursor appears to be at the end of the line, but when I start to type, the letters appear from the start of the line (and the cursor suddenly jumps to after the typed letters). Then after that, whenever I move the cursor to the very start of the text, it is drawn at the end of the line, but characters are still added to or deleted from the start. When I delete all the text at the end of the movie I’m pressing the Del button, not Backspace.

It’s in TextAssembler::calc_r_c

  if (n == 0) {
    // If there are no characters before n, no need to mess with soft
    // hyphens.
    c = row._string.size();

n is cursor position. Ask why if it’s 0, the column is filled with the row string size, instead of 0 ?