Notification when Scintilla.UndoRedo.CanUndo changes

Topics: User Forum
Aug 28, 2008 at 4:40 PM
I have implemented undo/redo, and have an "Edit" menu, where the enabled state of the "Undo" and "Redo" buttons are set in the DropDownOpening event. This means I can check CanUndo and CanRedo at that time.

Now - I'd like to add a toolbar with undo and redo buttons, and therefore in order to set the state of these buttons I need an event to be fired when CanUndo and CanRedo have changed.

Any other way of doing it? Guessing I could handle TextChanged event or similar, and update the buttons states then, but seems quite a lot of extra processing.


Aug 28, 2008 at 5:25 PM
I think that querying CanUndo and CanRedo during the DocumentChange event is your best bet. Scintilla doesn't expose events for CanUndo and CanRedo changes so that's what basically what ScintillaNet would have do if it were to implement those events. I'm fairly sure that calls to CanUndo and CanRedo are pretty cheap, and would be less expensive than the actual .NET event mechanisms. However I haven't profiled how long it takes to make native calls to Scintilla, that's a "someday" item.
Aug 28, 2008 at 5:30 PM
Thanks for the prompt reply Chris.

After posting I went back to the code and noticed I already handle the DocumentChange event - so I added the code I needed there as a quick fix until one of you guys got back to me!

Seems to work fine - and good to know that its the same method you would use.

Many thanks

Aug 28, 2008 at 5:34 PM
>>Thanks for the prompt reply Chris.
Yeah the CodePlex notifications have gotten a lot snappier. It used to take up to a couple of hours to get emails, now they're near instantaneous.