Like I said, you need to disable the Undo system completely and test saving feature. If it works correctly without the Undo, then you will know where to look for the problem.
And of course, if you are not calling "SaveStep" function, then undo won't work.
.
Try clicking anywhere on an empty space, hold the mouse button, move cursor to your sprite button and release. It will work as if the button was clicked.