static OSStatus playerEvtHandler(EventHandlerCallRef nextHdlr, EventRef thisEvt, void *pvUserData) { ControlRef cRef; ControlID cID; OSStatus iErr; UInt32 iSize, iPos; HIPoint pMouse; Rect rDims; int iPct; if ( (kEventClassWindow == GetEventClass(thisEvt)) && (kEventWindowClose == GetEventKind(thisEvt)) ) { HideWindow(g_refPlayerWin); g_bVisible = false; return noErr; } else if ( (kEventClassControl == GetEventClass(thisEvt)) && (kEventControlClick == GetEventKind(thisEvt)) ) { if (noErr != (iErr = GetEventParameter(thisEvt, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(Point), NULL, &pMouse))) { fprintf(stderr, "playerEvtHandler() - GetEventParameter(HitTest) failed, returning %lu!\n", (unsigned long) iErr); } cID.signature = FOUR_CHAR_CODE('fpos'); cID.id = 7; if (noErr == (iErr = GetControlByID(g_refPlayerWin, &cID, &cRef))) { GetControlBounds(cRef, &rDims); iSize = rDims.right - rDims.left; iPos = (UInt32) pMouse.x - rDims.left; iPct = (int) (100.0 * ((double) iPos) / ((double) iSize)); } else { fprintf(stderr, "playerEvtHandler() - GetControlByID() failed, returning %lu!\n", (unsigned long) iErr); } attemptSeekTo(iPct); return CallNextEventHandler(nextHdlr, thisEvt); } else { return CallNextEventHandler(nextHdlr, thisEvt); } }
//----------------------------------------------------------------------------------------------------------------------- static pascal OSStatus AppEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) { #pragma unused(inCallRef, inUserData) OSStatus err = eventNotHandledErr; UInt32 eventClass = GetEventClass(inEvent); UInt32 eventKind = GetEventKind(inEvent); if ( (eventClass == kEventClassCommand) && (eventKind == kEventCommandProcess) ) { HICommand command; GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &command ); switch ( command.commandID) { case kHICommandNew: NewCSkWindow(gOurNibRef, CSkToolPalette(gOurNibRef)); err = noErr; break; case kHICommandOpen: err = OpenAFile(); break; } } return err; } // AppEventHandlerProc
OSStatus simpleDialogHandler(EventHandlerCallRef handler, EventRef event, void *userdata) { OSStatus result = eventNotHandledErr; OSStatus err; UInt32 evtClass = GetEventClass(event); UInt32 evtKind = GetEventKind(event); WindowRef window = (WindowRef)userdata; if((evtClass == kEventClassCommand) && (evtKind == kEventCommandProcess)) { HICommand cmd; err = GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(cmd), NULL, &cmd); if(err == noErr) { switch(cmd.commandID) { case kHICommandOK: QuitAppModalLoopForWindow(window); result = noErr; break; case kHICommandCancel: QuitAppModalLoopForWindow(window); result = userCanceledErr; break; } } } return(result); }
bool AUCarbonViewBase::HandleEvent(EventRef event) { UInt32 eclass = GetEventClass(event); UInt32 ekind = GetEventKind(event); ControlRef control; switch (eclass) { case kEventClassControl: switch (ekind) { case kEventControlClick: GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control); if (control == mCarbonPane) { ClearKeyboardFocus(mCarbonWindow); return true; } } break; case kEventClassWindow: switch (ekind) { case kEventWindowClosed: printf("caught window-closed\n"); break; } break; } return false; }
static pascal OSStatus NPClientSheetEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { #pragma unused (inHandlerRef, inUserData) if (!npclient.dialogsheet) return (eventNotHandledErr); OSStatus err, result = eventNotHandledErr; switch (GetEventClass(inEvent)) { case kEventClassCommand: switch (GetEventKind(inEvent)) { case kEventCommandProcess: HICommand tHICommand; err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, nil, sizeof(HICommand), nil, &tHICommand); if (err == noErr) { switch (tHICommand.commandID) { case 'ok ': npclient.dialogprocess = kNPCDialogDone; result = noErr; } } } } return (result); }
OSStatus TabbedWindow::WindowHandleEvent( EventHandlerCallRef handler, EventRef event ) { OSStatus status = eventNotHandledErr; // process the event based on what type it is switch ( GetEventClass( event ) ) { case kEventClassControl: status = this->WindowHandleControlEvent( handler, event ); break; case kEventClassCommand: status = this->WindowHandleCommandEvent( handler, event ); break; case kEventClassMenu: status = this->WindowHandleMenuEvent( handler, event ); break; case kEventClassWindow: status = this->WindowHandleWindowEvent( handler, event ); break; default: status = eventNotHandledErr; break; } return status; }
static pascal OSStatus NPServerDialogEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; switch (GetEventClass(inEvent)) { case kEventClassCommand: switch (GetEventKind(inEvent)) { HICommand tHICommand; case kEventCommandUpdateStatus: err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand); if (err == noErr && tHICommand.commandID == 'clos') { UpdateMenuCommandStatus(false); result = noErr; } break; case kEventCommandProcess: err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand); if (err == noErr) { switch (tHICommand.commandID) { case 'OKAY': HIViewRef ctl, root; HIViewID cid; root = HIViewGetRoot(tWindowRef); cid.id = 0; cid.signature = 'OKAY'; HIViewFindByID(root, cid, &ctl); DeactivateControl(ctl); cid.signature = 'CNSL'; HIViewFindByID(root, cid, &ctl); DeactivateControl(ctl); npserver.dialogprocess = kNPSDialogProcess; result = noErr; break; case 'CNSL': npserver.dialogprocess = kNPSDialogCancel; result = noErr; break; } } break; } break; } return (result); }
static pascal OSStatus ViewClassHandler(EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon) { OSStatus result = eventNotHandledErr; int* pain = (int*)inRefcon; if (GetEventClass(inEvent) == kEventClassHIObject) { switch (GetEventKind(inEvent)) { case kEventHIObjectConstruct: { int* pa = new int; GetEventParameter(inEvent,kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(int), NULL, &pa); result = SetEventParameter(inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof(int), &pa); break; } case kEventHIObjectDestruct: { if (pain != NULL) { delete pain; } result = noErr; break; } } } return result; }
// --------------------------------------------------------------------------- // // ------------ bool bvDefScaleRef::wd_event(EventRef evt, WindowRef wd){ bool b=true; UInt32 clss=GetEventClass(evt); HICommand cmd; ControlRef c; bGenericUnit* u; if(clss==kEventClassCommand){ GetEventParameter(evt,kEventParamDirectObject,typeHICommand,NULL,sizeof(HICommand),NULL,&cmd); switch(cmd.commandID){ case kHICommandOK: write(); break; case kHICommandCancel: break; case kvDefScaleRefPopupCmd: c=get_control(kvDefScaleRefViewSignature,kvDefScaleRefPopupID); _idx=GetControl32BitValue(c); if(_idx>2){ u=_gapp->scaleMgr()->get(_idx-2); _scale=u->coef(); } else{ _scale=0; } break; default: b=false; break; } } return(b); }
pascal OSStatus AutofireWindowEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { #pragma unused (inHandlerRef) OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; switch (GetEventClass(inEvent)) { case kEventClassWindow: switch (GetEventKind(inEvent)) { case kEventWindowClose: QuitAppModalLoopForWindow(tWindowRef); result = noErr; } break; case kEventClassCommand: switch (GetEventKind(inEvent)) { case kEventCommandProcess: HICommand tHICommand; HIViewRef root; int player = -1; root = HIViewGetRoot(tWindowRef); err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, nil, sizeof(HICommand), nil, &tHICommand); if (err == noErr) { switch (tHICommand.commandID) { case 'DEF1': player = 0; break; case 'DEF2': player = 1; break; } if (player != -1) { autofireRec[player].buttonMask = 0x0000; autofireRec[player].toggleMask = 0xFFF0; autofireRec[player].tcMask = 0x0000; autofireRec[player].invertMask = 0x0000; autofireRec[player].frequency = 10; AutofireReadAllSettings(player + 1, root); result = noErr; } } } } return result; }
//------------------------------------------------------------------------------------------------------- pascal OSStatus windowHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus result = eventNotHandledErr; WindowRef window = (WindowRef) inUserData; UInt32 eventClass = GetEventClass (inEvent); UInt32 eventKind = GetEventKind (inEvent); switch (eventClass) { case kEventClassWindow: { switch (eventKind) { case kEventWindowClose: { QuitAppModalLoopForWindow (window); break; } } break; } } return result; }
static pascal OSStatus eventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData ) { ::UInt32 eventClass = GetEventClass(event); CSMNativeWindow *pWin = reinterpret_cast<CSMNativeWindow *>(userData); OSG_ASSERT(pWin != NULL); switch (eventClass) { // Mouse events case kEventClassMouse: return pWin->handleMouseEvent(nextHandler, event); // Key press events case kEventClassTextInput: return pWin->handleKeyEvent(nextHandler, event); // Window events case kEventClassWindow: return pWin->handleWindowEvent(nextHandler, event); default: return eventNotHandledErr; } }
// -------------------------------------------------------------------------------------- static pascal OSStatus dialogEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *prefsDialog) { #pragma unused (nextHandler) OSStatus result = eventNotHandledErr; UInt32 eventClass, eventKind; ControlRef controlHit; ControlID controlID; eventClass = GetEventClass(event); eventKind = GetEventKind(event); switch (eventClass) { case kEventClassControl: switch (eventKind) { case kEventControlHit: GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &controlHit); GetControlID(controlHit, &controlID); handleDialogItemHit((DialogRef)prefsDialog, (DialogItemIndex)controlID.id); result = noErr; break; } break; } return result; }
static pascal OSStatus AppEventEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) { #pragma unused ( inCallRef, inUserData ) HICommand command; OSStatus err = eventNotHandledErr; UInt32 eventClass = GetEventClass( inEvent ); UInt32 eventKind = GetEventKind(inEvent); switch ( eventClass ) { case kEventClassCommand: GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &command ); if ( eventKind == kEventCommandProcess ) { if ( command.commandID == kHICommandNew ) { DisplaySimpleWindow(); } else if ( command.commandID == kHICommandOpen ) // Open... menu choice { OpenFiles(); } } break; } return( err ); }
MODULE_SCOPE char * TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char * buf ) { EventClass eventClass; EventKind eventKind; MyEventNameList * list = eventNameList; MyEventName * names = NULL; int found = 0; eventClass = GetEventClass(eventRef); eventKind = GetEventKind(eventRef); while (list->names && (!names) ) { if (eventClass == list -> c) { names = list -> names; } else { list++; } } if (names) { found = 0; while ( names->name && !found ) { if (eventKind == names->kind) { sprintf(buf,"%s",names->name); found = 1; } else { names++; } } } if (!found) { sprintf ( buf,"%d", eventKind ); } else { sprintf ( buf,"%d", eventKind ); } return buf; }
bool XControl::HandleEvent(EventRef event) { if (!mListener) return false; UInt32 eclass = GetEventClass(event); UInt32 ekind = GetEventKind(event); ControlRef control; switch (eclass) { case kEventClassControl: switch (ekind) { case kEventControlValueFieldChanged: { GetEventParameter(event, kEventParamDirectObject, kEventParamControlRef, NULL, sizeof(ControlRef), NULL, &control); mListener->ControlValueChanged (this); return true; } } } return false; }
static pascal OSStatus IndicatorEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData) { #pragma unused (inHandlerCallRef) OSStatus err, result = eventNotHandledErr; HIViewRef view = (HIViewRef) userData; switch (GetEventClass(inEvent)) { case kEventClassControl: switch (GetEventKind(inEvent)) { case kEventControlDraw: CGContextRef ctx; err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, nil, sizeof(CGContextRef), nil, &ctx); if (err == noErr) { HIRect bounds; HIViewGetBounds(view, &bounds); CGContextTranslateCTM(ctx, 0, bounds.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); MusicBoxDrawIndicator(view, ctx); result = noErr; } } } return result; }
static pascal OSStatus s86proc(EventHandlerCallRef myHandler, EventRef event, void* userData) { OSStatus err = eventNotHandledErr; HIPoint pos; Point p; Rect ctrlbounds, winbounds; PicHandle pict; if (GetEventClass(event)==kEventClassControl && GetEventKind(event)==kEventControlClick ) { err = noErr; GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &pos); GetControlBounds((ControlRef)userData, &ctrlbounds); GetWindowBounds(soundWin, kWindowContentRgn, &winbounds); p.h = (short)pos.x; p.h -= (ctrlbounds.left + winbounds.left); p.h /= 8; if ((p.h < 2) || (p.h >= 10)) { return(err); } p.h -= 2; snd86 ^= (1 << p.h); set86s(); setbmp(dipswbmp_getsnd86(snd86), &pict); SetControlData((ControlRef)userData, kControlNoPart, kControlPictureHandleTag, sizeof(PicHandle), &pict); Draw1Control((ControlRef)userData); } (void)myHandler; (void)userData; return err; }
IEventQueueBuffer::Type OSXEventQueueBuffer::getEvent(Event& event, UInt32& dataID) { // release the previous event if (m_event != NULL) { ReleaseEvent(m_event); m_event = NULL; } // get the next event OSStatus error = ReceiveNextEvent(0, NULL, 0.0, true, &m_event); // handle the event if (error == eventLoopQuitErr) { event = Event(Event::kQuit); return kSystem; } else if (error != noErr) { return kNone; } else { UInt32 eventClass = GetEventClass(m_event); switch (eventClass) { case 'Syne': dataID = GetEventKind(m_event); return kUser; default: event = Event(Event::kSystem, m_eventQueue->getSystemTarget(), &m_event); return kSystem; } } }
// -------------------------------------------------------------------------------------- static pascal OSStatus appEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *junk) { #pragma unused (nextHandler, junk) OSStatus result = eventNotHandledErr; UInt32 eventClass, eventKind; HICommand command; eventClass = GetEventClass(event); eventKind = GetEventKind(event); switch (eventClass) { case kEventClassCommand: switch (eventKind) { case kEventCommandProcess: GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &command); result = handleCommand(command); break; } break; } return result; }
// --------------------------------------------------------------------------- // // ----------- bool bToolShape::edit_event(EventRef evt, WindowRef wd){ bool b=true; HICommand cmd; ControlRef c; ControlID cid={kShapeEditSign,kShapeCenterID}; if(GetEventClass(evt)==kEventClassCommand){ GetEventParameter(evt,kEventParamDirectObject,typeHICommand,NULL,sizeof(HICommand),NULL,&cmd); switch(cmd.commandID){ case kHICommandOK: GetControlByID(wd,&cid,&c); _ctr=GetControl32BitValue(c); cid.id=kShapeOpenFicheID; GetControlByID(wd,&cid,&c); _opn=GetControl32BitValue(c); cid.id=kShapeCMMeasID; GetControlByID(wd,&cid,&c); _cm=GetControl32BitValue(c); break; case kHICommandCancel: break; default: b=false; break; } } return(b); }
static pascal OSStatus ApplicationEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) // Dispatches HICommands to their implementations. { OSStatus err; HICommand command; #pragma unused(inHandlerCallRef) #pragma unused(inUserData) assert( GetEventClass(inEvent) == kEventClassCommand ); assert( GetEventKind(inEvent) == kEventCommandProcess); err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(command), NULL, &command); if (err == noErr) { switch (command.commandID) { case kHICommandAbout: DoAbout(); break; case 'DShw': DoRefresh(); break; case 'DAdd': DoAddTest(); break; case 'DRem': DoRemoveTest(); break; default: err = eventNotHandledErr; break; } } return err; }
static OSStatus handle_spy_event(EventHandlerCallRef handler_call_chain, EventRef e, void* data) { QuartzWindow *w = (QuartzWindow*)data; if ( GetEventClass(e) == kEventClassWindow ) switch (GetEventKind(e)) { case kEventWindowBoundsChanged: w->set_bounds_changed(); break; case kEventWindowClose: w->set_was_closed(); break; } return noErr; }
pascal OSStatus HIOpenGLViewEventProc (EventHandlerCallRef inCall, EventRef inEvent, void* inUserData) { HIOpenGLViewData* data = (HIOpenGLViewData*)inUserData; switch (GetEventClass(inEvent)) { case kEventClassHIObject: return HIOpenGLViewEventHIObject(inCall, inEvent, data); break; case kEventClassControl: return HIOpenGLViewEventControl(inCall, inEvent, data); break; default: return eventNotHandledErr; break; } }
OSStatus dialogHandler(EventHandlerCallRef handler, EventRef event, void *userdata) { OSStatus result = eventNotHandledErr; OSStatus err; UInt32 evtClass = GetEventClass(event); UInt32 evtKind = GetEventKind(event); if((evtClass == kEventClassCommand) && (evtKind == kEventCommandProcess)) { HICommand cmd; err = GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(cmd), NULL, &cmd); if(err == noErr) { switch(cmd.commandID) { case kHICommandCancel: gCancelled = true; // QuitAppModalLoopForWindow(gWindow); result = noErr; break; } } } else if((evtClass == kEventClassCustom) && (evtKind == kEventCustomProgress)) { // Request to update the progress dialog long cur = 0; long max = 0; CFStringRef text = NULL; (void) GetEventParameter(event, kEventParamCustomCurValue, typeLongInteger, NULL, sizeof(cur), NULL, &cur); (void) GetEventParameter(event, kEventParamCustomMaxValue, typeLongInteger, NULL, sizeof(max), NULL, &max); (void) GetEventParameter(event, kEventParamCustomText, typeCFStringRef, NULL, sizeof(text), NULL, &text); err = setProgress(cur, max); if(err == noErr) { if(text != NULL) { setProgressText(text); } } result = noErr; } else if((evtClass == kEventClassCustom) && (evtKind == kEventCustomDone)) { // We're done. Exit the modal loop. QuitAppModalLoopForWindow(gWindow); result = noErr; } return(result); }
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &, void *message, long *) { EventRef event = (EventRef) message; if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) { EventHotKeyID keyID; GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, nullptr, sizeof(keyID), nullptr, &keyID); Identifier id = keyIDs.key(keyID.id); activateShortcut(id.second, id.first); } return false; }
void print_event(EventRef evt) { uint32 cl = EndianU32_NtoB(GetEventClass(evt)); uint32 ki = /*EndianU32_NtoB*/(GetEventKind(evt)); lprintf("Event class: %4.4s kind: %d ", (char*)&cl, ki); lprintf("\tbtn: 0x%x ", get_scalar_event_parm(evt, kEventParamMouseButton, typeMouseButton)); // lprintf("\ttarg: 0x%x\n", get_scalar_event_parm(evt, kEventParamDirectObject, typeWildCard)); lprintf("\ttarg: 0x%x ", get_scalar_event_parm(evt, kEventParamPostTarget, typeEventTargetRef)); lprintf("\twind: 0x%x ", get_scalar_event_parm(evt, kEventParamWindowRef, typeWindowRef)); lprintf("\tgrafport: 0x%x\n", get_scalar_event_parm(evt, kEventParamGrafPort, typeGrafPtr)); }
static OSStatus infoEvtHandler(EventHandlerCallRef nextHdlr, EventRef thisEvt, void *pvUserData) { if ( (kEventClassWindow != GetEventClass(thisEvt)) || (kEventWindowClose != GetEventKind(thisEvt)) ) { return CallNextEventHandler(nextHdlr, thisEvt); } HideWindow(g_refInfoWin); g_bVisible = false; return noErr; }
pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ; wxTheApp->MacSetCurrentEvent( event , handler ) ; OSStatus result = eventNotHandledErr ; switch ( GetEventClass( event ) ) { case kEventClassCommand : result = wxMacAppCommandEventHandler( handler , event , data ) ; break ; case kEventClassApplication : result = wxMacAppApplicationEventHandler( handler , event , data ) ; break ; case kEventClassMenu : result = wxMacAppMenuEventHandler( handler , event , data ) ; break ; case kEventClassMouse : { wxMacCarbonEvent cEvent( event ) ; WindowRef window ; Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ; ::FindWindow(screenMouseLocation, &window); // only send this event in case it had not already been sent to a tlw, as we get // double events otherwise (in case event.skip) was called if ( window == NULL ) result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ; } break ; case kEventClassAppleEvent : { EventRecord rec ; wxMacConvertEventToRecord( event , &rec ) ; result = AEProcessAppleEvent( &rec ) ; } break ; default : break ; } wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ; return result ; }
OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) { Q_UNUSED(nextHandler); Q_UNUSED(data); if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) { EventHotKeyID keyID; GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); Identifier id = keyIDs.key(keyID.id); QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); } return noErr; }