[Project_owners] Manually adding things to the undo pile

David Murray lid2000 at tpg.com.au
Tue Oct 14 19:57:42 EDT 2003


I've got a textbox, all nice and happy, as textboxes usually are. 
Undo/Redo works fine on it. However, I've got it so that if you press 
Ctrl+B, it calls a function that adds <b></b> tags around whatever text 
is selected. It works all fine, except as soon as the function runs, it 
clears out all the undo memory. It seems that settling textbox.value 
wipes resets the undo pile.

I can't find any ways to preserve the undo history if you change the 
value in a textbox via Javascript. I was looking at 
http://www.xulplanet.com/references/xpcomref/group_ClipboardandSelection.html#Transactions 
to see if the Transaction Manager thing would work, but I can't even get 
it to start.

tManager = 
Components.classes["@mozilla.org/transactionmanager;1"].createInstance(QueryInterface(Components.interfaces.nsITransaction));

Doing that just generates a NS_NOINTERFACE error (on Mozilla 1.4.1 
anyway). I'm well and truly out of ideas. I thought this'd be a common 
problem for XUL stuff but I can't find anything on the Internet about 
preserving the undo pile while changing textbox values through 
Javascript. Has anyone managed to successfully do this?

David.
http://deepestsender.mozdev.org




More information about the Project_owners mailing list