Created
August 30, 2013 09:01
-
-
Save prashantvc/6387861 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MonoMac.Foundation; | |
using MonoMac.AppKit; | |
namespace PopOverSample | |
{ | |
public partial class MainWindowController : NSWindowController | |
{ | |
#region Constructors | |
// Called when created from unmanaged code | |
public MainWindowController (IntPtr handle) : base (handle) | |
{ | |
Initialize (); | |
} | |
// Called when created directly from a XIB file | |
[Export ("initWithCoder:")] | |
public MainWindowController (NSCoder coder) : base (coder) | |
{ | |
Initialize (); | |
} | |
// Call to load from the XIB/NIB file | |
public MainWindowController () : base ("MainWindow") | |
{ | |
Initialize (); | |
} | |
// Shared initialization code | |
void Initialize () | |
{ | |
} | |
public override void WindowDidLoad () | |
{ | |
base.WindowDidLoad (); | |
popOver.Delegate = new MyPopOverDelegate (); | |
} | |
public class MyPopOverDelegate: NSPopoverDelegate { | |
public override void DidShow (NSNotification notification) | |
{ | |
Console.WriteLine ("Popover displayed"); | |
} | |
public override void DidClose (NSNotification notification) | |
{ | |
Console.WriteLine ("Popover closed"); | |
} | |
} | |
#endregion | |
//strongly typed window accessor | |
public new MainWindow Window { | |
get { | |
return (MainWindow)base.Window; | |
} | |
} | |
partial void ShowPopOver (NSObject sender) | |
{ | |
if (popOver.Shown) { | |
popOver.Close(); | |
return; | |
} | |
NSButton button = (NSButton) sender; | |
popOver.Show(button.Bounds, button, NSRectEdge.MaxYEdge); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment