MODULE_SCOPE void TkMacOSXInitCarbonEvents( Tcl_Interp *interp) { const EventTypeSpec dispatcherEventTypes[] = { {kEventClassKeyboard, kEventRawKeyDown}, {kEventClassKeyboard, kEventRawKeyRepeat}, {kEventClassKeyboard, kEventRawKeyUp}, {kEventClassKeyboard, kEventRawKeyModifiersChanged}, {kEventClassKeyboard, kEventRawKeyRepeat}, }; const EventTypeSpec applicationEventTypes[] = { {kEventClassMenu, kEventMenuBeginTracking}, {kEventClassMenu, kEventMenuEndTracking}, {kEventClassMenu, kEventMenuOpening}, {kEventClassMenu, kEventMenuTargetItem}, {kEventClassCommand, kEventCommandProcess}, {kEventClassCommand, kEventCommandUpdateStatus}, {kEventClassApplication, kEventAppActivated}, {kEventClassApplication, kEventAppDeactivated}, {kEventClassApplication, kEventAppQuit}, {kEventClassApplication, kEventAppHidden}, {kEventClassApplication, kEventAppShown}, {kEventClassApplication, kEventAppAvailableWindowBoundsChanged}, {kEventClassAppearance, kEventAppearanceScrollBarVariantChanged}, {kEventClassFont, kEventFontPanelClosed}, {kEventClassFont, kEventFontSelection}, }; carbonEventHandlerUPP = NewEventHandlerUPP(CarbonEventHandlerProc); carbonEventInterp = interp; ChkErr(InstallStandardApplicationEventHandler); ChkErr(InstallEventHandler, GetEventDispatcherTarget(), carbonEventHandlerUPP, GetEventTypeCount(dispatcherEventTypes), dispatcherEventTypes, (void *) carbonEventInterp, NULL); ChkErr(InstallEventHandler, GetApplicationEventTarget(), carbonEventHandlerUPP, GetEventTypeCount(applicationEventTypes), applicationEventTypes, (void *) carbonEventInterp, NULL); #ifdef TK_MAC_DEBUG_CARBON_EVENTS TkMacOSXInitNamedSymbol(HIToolbox, void, DebugTraceEvent, OSType, UInt32, Boolean); if (DebugTraceEvent) { unsigned int i; const EventTypeSpec *e; for (i = 0, e = dispatcherEventTypes; i < GetEventTypeCount(dispatcherEventTypes); i++, e++) { DebugTraceEvent(e->eventClass, e->eventKind, 1); } for (i = 0, e = applicationEventTypes; i < GetEventTypeCount(applicationEventTypes); i++, e++) { DebugTraceEvent(e->eventClass, e->eventKind, 1); } DebugTraceEvent = NULL; /* Only enable tracing once. */ } #endif /* TK_MAC_DEBUG_CARBON_EVENTS */ }
MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler( Tcl_Interp *interp, WindowRef window) { const EventTypeSpec windowEventTypes[] = { {kEventClassMouse, kEventMouseDown}, {kEventClassMouse, kEventMouseUp}, {kEventClassMouse, kEventMouseMoved}, {kEventClassMouse, kEventMouseDragged}, {kEventClassMouse, kEventMouseWheelMoved}, {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowUpdate}, {kEventClassWindow, kEventWindowExpanding}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowDragStarted}, {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassWindow, kEventWindowConstrain}, {kEventClassWindow, kEventWindowGetRegion}, {kEventClassWindow, kEventWindowDrawContent}, }; ChkErr(InstallEventHandler, GetWindowEventTarget(window), carbonEventHandlerUPP, GetEventTypeCount(windowEventTypes), windowEventTypes, (void *) (interp ? interp : carbonEventInterp), NULL); #ifdef TK_MAC_DEBUG_CARBON_EVENTS TkMacOSXInitNamedSymbol(HIToolbox, void, DebugTraceEvent, OSType, UInt32, Boolean); if (DebugTraceEvent) { unsigned int i; const EventTypeSpec *e; for (i = 0, e = windowEventTypes; i < GetEventTypeCount(windowEventTypes); i++, e++) { if (!(e->eventClass == kEventClassMouse && ( e->eventKind == kEventMouseMoved || e->eventKind == kEventMouseDragged))) { DebugTraceEvent(e->eventClass, e->eventKind, 1); } } } #endif /* TK_MAC_DEBUG_CARBON_EVENTS */ }