I need to subclass NSApplication in MonoMac to override the sendEvent (SendEvent in C# terms) method of NSApplication in order to receive media key events (Play, Pause, Next, Prev on Macbooks) as described here: Listening to mac keyboard play/pause events and here: https://bitbucket.org/nkreeger/whitedragon/src/6f530c8a34a7/component/sbAppleMediaKeyController.mm
So far I came up with this code:
class MainClass
{
static void Main (string[] args)
{
MyApp.Init ();
MyApp.Main (args);
}
}
class MyApp : NSApplication
{
public override void SendEvent (NSEvent theEvent)
{
Console.WriteLine ("event received!");
base.SendEvent (theEvent);
}
public override void SetMainMenu (NSMenu aMenu)
{
Console.WriteLine ("main menu set!");
base.SetMainMenu (aMenu);
}
}
But neither SendEvent or SetMainMenu (which I added for testing purposes as SetMainMenu should be called once on startup) are called, as I don't get any console output.
What is the correct way of doing this?