static OSStatus EventHandler(IntPtr inCaller, IntPtr inEvent, IntPtr userData) { EventInfo evt = new EventInfo(inEvent); switch (evt.EventClass) { case EventClass.Application: switch (evt.AppEventKind) { case AppEventKind.AppQuit: API.RemoveEventHandler(uppHandler); return(OSStatus.EventNotHandled); default: return(OSStatus.EventNotHandled); } case EventClass.AppleEvent: // only event here is the apple event. Debug.Print("Processing apple event."); API.ProcessAppleEvent(inEvent); break; case EventClass.Keyboard: case EventClass.Mouse: if (WindowEventHandler != null) { return(WindowEventHandler.DispatchEvent(inCaller, inEvent, evt, userData)); } break; } return(OSStatus.EventNotHandled); }