It works if I set the delegate in interface builder for the window to
MyWindow, and if I modify my code to :
using System;
using System.Collections.Generic;
using System.Text;
using Monobjc;
using Monobjc.Cocoa;
namespace windows_events
{
[ObjectiveCClass]
public class MyWindow : NSObject
{
public MyWindow() : base() { }
public MyWindow(IntPtr native_object) : base(native_object) { }
[ObjectiveCMessage(awakeFromNib)]
public void awakeFromNib()
{
Console.WriteLine(this.GetType().ToString() + :
awakeFromNib);
}
[ObjectiveCMessage(windowWillClose:)]
public void windowWillClose(NSNotification notification)
{
Console.WriteLine(window closes);
}
}
}
Cheers,
Miguel
Miguel De Buf wrote:
Hi,
I try to catch a window close event in my controller class, but the
eventhandler never gets executed. This is my code :
using System;
using System.Collections.Generic;
using System.Text;
using Monobjc;
using Monobjc.Cocoa;
namespace windows_events
{
[ObjectiveCClass]
public class MyWindow : NSWindow
{
public MyWindow() : base() { }
public MyWindow(IntPtr native_object) : base(native_object) { }
[ObjectiveCMessage(awakeFromNib)]
public void awakeFromNib()
{
Console.WriteLine(this.GetType().ToString() + :
awakeFromNib);
this.WindowWillClose += new
WindowWillCloseEventHandler(MyWindow_WindowWillClose);
}
void MyWindow_WindowWillClose(NSNotification notification)
{
Console.WriteLine(window closes);
}
}
}
The documentation says, just add an event handler. So I subclassed
from NSWindow and just added an event handler, but it never gets
executed.
Why ?
Many thanks,
Miguel