Myra
Myra copied to clipboard
TextBox UndoRedoStack ArgumentOutOfRangeException
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()
I think adding UndoRedoEnabled property is great idea.
Though public method ResetUndoRedoStack wouldn't hurt either.
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 .
The initial problem(crash when Undo) might have been fixed in the new release (1.0.0.205).
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 .
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.
Thanks for the info.