[Mono-osx] Window.WindowShouldClose

CircleOf14 alfredomachin at hotmail.com
Fri Oct 21 04:59:54 EDT 2011


Don't know if this might help. I got WindowShouldClose() to work by creating
a separate class and delegate. I created a brand new class:

	public class WinDelegate : NSWindowDelegate
	{		
		public WinDelegate (){}
		
		public override bool WindowShouldClose (MonoMac.Foundation.NSObject
sender)
		{
			NSAlert alert = NSAlert.WithMessage("Are you sure you want to exit?",
"Yes", "No", null, "Warning!");
				
			var button = alert.RunModal();
				
			if ( button == 0 ){return false;}
		        else{return true;}			
		}
	}

Then from the window class in question just declare this in Initialize():
this.Window.Delegate = new WinDelegate();

Not sure if that's what you're looking for. Let me know if it works out.


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


More information about the Mono-osx mailing list