Skip to content

Instantly share code, notes, and snippets.

@chamons
Created May 5, 2015 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamons/bc7d951b009cab8b7a63 to your computer and use it in GitHub Desktop.
Save chamons/bc7d951b009cab8b7a63 to your computer and use it in GitHub Desktop.
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