[Mono-osx] NSDrawer Implementation

kjpou1 kjpou at pt.lu
Thu Nov 4 11:45:41 EDT 2010


Hello all

First want to apologize for the length.  If I am breaking rules please let
me know. 

I have finished up the DrawerMadness sample but had to change the appkit
sources locally to add the following:

NSDrawerState

NSDrawerDelegate

Modify the NSDrawer class to use the NSDrawerDelegate.

All is working but was wondering about the prevailing thought on the
Delegate classes VS Events and Delegates.  I have implemented it both ways
just to see the difference myself and really can not decide.

1) The first way was for doing the following:

Define the delegate class and attach it to the Drawer Delegate method

ex.  

	public class MyDrawerDelegate : NSDrawerDelegate
	{
		
		private ParentWindowController controller;
		
		public MyDrawerDelegate(ParentWindowController controller):base() 
		{
			this.controller = controller;
		}
               ....... Other methods of interest go here .......

		public SizeF DrawerWillResizeContents (NSDrawer sender, SizeF contentSize)
		{
    		
			return contentSize;
			
		}
	}

lowerRightDrawer.Delegate = new MyDrawerDelegate;


2) The second way is for using Events and Delegates

Example

lowerRightDrawer.DrawerWillResizeContents = 
					new NSDrawerWillResizeContentsDelegate(DrawerWillResizeContents);

lowerRightDrawer.DrawerShouldClose = new
NSDrawerShouldCloseDelegate(DrawerShouldClose);

lowerRightDrawer.DrawerWillClose += delegate(object sender, EventArgs e) {
				Console.WriteLine("Drawer will Close");
			};

Which is preferred method that is used or is there one?

Kenneth



-- 
View this message in context: http://mono.1490590.n4.nabble.com/NSDrawer-Implementation-tp3027262p3027262.html
Sent from the Mono - OSX mailing list archive at Nabble.com.


More information about the Mono-osx mailing list