Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using Foundation;
using AppKit;
namespace TextViewTest
{
public class StdMyDel : NSTextViewDelegate
{
public override void TextDidChange (NSNotification notification)
{
Console.WriteLine ("standardTextView: TextDidChange");
}
}
public class CustMyDel : NSTextViewDelegate
{
public override void TextDidChange (NSNotification notification)
{
Console.WriteLine ("customTextView: TextDidChange");
}
}
public partial class MainWindow : NSWindow
{
private CustomTextView customTextView;
private NSTextView standardTextView;
public MainWindow (IntPtr handle) : base (handle)
{
}
[Export ("initWithCoder:")]
public MainWindow (NSCoder coder) : base (coder)
{
}
public override void AwakeFromNib ()
{
base.AwakeFromNib ();
customTextView = new CustomTextView (new CoreGraphics.CGRect (10, 10, 200, 24));
customTextView.FinishedEditing += () => Console.WriteLine("Shift Enter Pressed");
customTextView.Delegate = new CustMyDel ();
ContentView.AddSubview (customTextView);
standardTextView = new NSTextView (new CoreGraphics.CGRect (10, 50, 200, 24));
standardTextView.BackgroundColor = NSColor.LightGray;
standardTextView.Delegate = new StdMyDel ();
ContentView.AddSubview (standardTextView);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment