Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NSUndoManager _undo;
public override void AwakeFromNib ()
{
base.AwakeFromNib ();
_undo = new NSUndoManager ();
DisplayField.StringValue = "0";
PlusOneButton.Activated += (sender, e) => Increment(null);
MinusOneButton.Activated += (sender, e) => Decrement(null);
UndoButton.Activated += (sender, e) => _undo.Undo ();
RedoButton.Activated += (sender, e) => _undo.Redo ();
}
Selector _incrementSelector = new Selector ("Increment");
Selector _decrementSelector = new Selector ("Decrement");
[Export("Decrement")]
void Decrement (NSObject o)
{
_undo.RegisterUndoWithTarget (this, _incrementSelector, new NSObject());
_undo.SetActionname ("Subtract");
DisplayField.StringValue = (DisplayField.IntValue - 1).ToString ();
}
[Export("Increment")]
void Increment (NSObject o)
{
_undo.RegisterUndoWithTarget (this, _decrementSelector, new NSObject());
_undo.SetActionname ("Add");
DisplayField.StringValue = (DisplayField.IntValue + 1).ToString ();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.