[Project_owners] Manually adding things to the undo pile

Neil Deakin enndeakin at sympatico.ca
Tue Oct 14 13:48:18 EDT 2003


mark bokil wrote:

>>> This is my experience also. If you change your textbox value it will 
>>> automatically wipe the undo pile. I would be interested if you come 
>>> up with a way to prevent this.
>>>
>>> -mark
>>>
>> If you change the value of a textbox via a script, it shouldn't be 
>> undoable since there isn't any user text to go back to. The change 
>> made by the script certainly shouldn't be undoable. If it was, I 
>> could imagine all sorts of breakage as users undo things they shouldn't.
>>
>> / Neil
>
>
> Say I have a script that adds comment marks to the front of a line. I 
> would need to add this change to the undo pile so that an undo would 
> cause the line to revert to their uncommented state. How do you insert 
> items into the undo pile?
>
> -mark
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>
I think you do this by creating an nsITransaction and adding it to the 
transaction manager. The transaction does the operation and handles 
undo/redo. There's an example in 
chrome://editor/content/EditorCommandsDebug.js

/ Neil




More information about the Project_owners mailing list