Problem with textbox.Value

Oct 9, 2012 at 7:24 PM
Edited Oct 9, 2012 at 7:37 PM

Hello,

I can't update the value of textbox.Valu

It seems like the function Delete(), in TextBoxRenderRule.cs, is not working.

When I try to remove a char, the value is not updated.

When I write again, only the chars in specific positions are overwriten.

public void Delete() {

            if (HasSelected) {
                RemoveSelected();
                return;
            }

            if (Length == 0 || TextCursor == Length) { return; }

            var start = TextCursor + 1;
            Array.Copy(_char, start, _char, TextCursor, Length - start);
            Array.Copy(_charWidth, start, _charWidth, TextCursor, Length - start);

            Length--;
            Remeasure();
        }

}

Could you see what is wrong?

 

Thanks.

Coordinator
Oct 10, 2012 at 5:43 AM

Thanks for creating an issue :) I meant to create one from your post but kept getting distracted by other stuff. I'll try and work on it by this weekend. 

Oct 15, 2012 at 5:05 PM
Edited Oct 16, 2012 at 1:33 AM

Hi,

I think I have found the bug.

It worked for me with changing the variable Length in the statement Array.Copy(_char, start, _char, TextCursor, Length - start) to the variable MaxLength.

So, the new statement would be Array.Copy(_char, start, _char, TextCursor, MaxLength - start)

That is why the copy is from the whole textbox array (MaxLength) and not only from the text inside it (Length).

To solve the last character standing, put this line after that:

_char[MaxLength - 1] = Convert.ToChar("\0");

 I don't know if it is so ellegant, or if there is a better way. But, it works with backspace and delete actions.

 

Could you check it, please?

Thanks.

Coordinator
Oct 19, 2012 at 3:31 AM

Should be fixed in the latest commit.