Myra icon indicating copy to clipboard operation
Myra copied to clipboard

TextBox UndoRedoStack ArgumentOutOfRangeException

Open Nornec opened this issue 4 years ago • 7 comments

After setting a TextBox object back to a Text value of "" after typing some text, when attempting to "undo" with Ctrl+Z, an exception is thrown. Should it be possible to disable the undo/redo functionality of a dynamic text box with a property? For example: UndoRedoEnabled, or some way to clear/reset the UndoRedoStack.

If there is another method that I could use to get around this issue, I'm open to other suggestions. Right now I have multiple canvas objects that have an editable "label" property that is set by a TextBox, but the TextBox object is shared among all canvas objects inside of a properties pane, depending on which canvas objects are chosen (1 or many).

System.ArgumentOutOfRangeException: 'startIndex cannot be larger than length of string. Parameter name: startIndex' This exception was originally thrown at this call stack: string.Substring(int, int) Myra.Graphics2D.UI.TextEdit.UndoRedoStack.MakeDelete(string, int, int) Myra.Graphics2D.UI.TextBox.UndoRedo(Myra.Graphics2D.UI.TextEdit.UndoRedoStack, Myra.Graphics2D.UI.TextEdit.UndoRedoStack) Myra.Graphics2D.UI.TextBox.OnKeyDown(Microsoft.Xna.Framework.Input.Keys) Myra.Graphics2D.UI.Desktop.OnKeyDown(Microsoft.Xna.Framework.Input.Keys) Myra.Graphics2D.UI.Desktop.UpdateKeyboardInput() Myra.Graphics2D.UI.Desktop.UpdateInput() Myra.Graphics2D.UI.Desktop.Render()

Nornec avatar May 16 '20 17:05 Nornec

I think adding UndoRedoEnabled property is great idea.

rds1983 avatar Jun 12 '20 14:06 rds1983

Though public method ResetUndoRedoStack wouldn't hurt either.

rds1983 avatar Jun 12 '20 14:06 rds1983

yes both great ideas, my thought was a situation where a program has its own UR stack, it would want a way to disable or control other stacks for object types. or in a combo situation, reset would be an elegant solution that could be coupled.

On Fri, Jun 12, 2020, 10:52 Roman Shapiro [email protected] wrote:

Though public method ResetUndoRedoStack wouldn't hurt either.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rds1983/Myra/issues/215#issuecomment-643314568, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQ2UVT2GXSMD4ATB47QFMTRWI6MXANCNFSM4NC76Z5A .

Nornec avatar Jun 12 '20 15:06 Nornec

The initial problem(crash when Undo) might have been fixed in the new release (1.0.0.205).

rds1983 avatar Jul 28 '20 06:07 rds1983

Thanks, i will update and test.

On Tue, Jul 28, 2020, 02:32 Roman Shapiro [email protected] wrote:

The initial problem(crash when Undo) might have been fixed in the new release (1.0.0.205).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rds1983/Myra/issues/215#issuecomment-664806475, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQ2UVT5744ACU2Y2IXIKULR5ZWI3ANCNFSM4NC76Z5A .

Nornec avatar Jul 28 '20 12:07 Nornec

The exception still happens in the same manner. Here's a more detailed explanation on how to reproduce: Object 1 is selected. A properties pane opens and the name TextBox field is populated by the object's name property. Object 1 is given a longer name by inputting more text.

Object 2 is selected. The same properties pane (represented by the same UI elements) is cleared and set to the current object's properties. Object 2 has not been given a name yet so the name TextBox is blank. If I try to use Cntl+Z to undo, the exception occurs as described above.

Nornec avatar Jul 30 '20 00:07 Nornec

Thanks for the info.

rds1983 avatar Jul 30 '20 01:07 rds1983