예제 #1
0
파일: PlayerWin.cpp 프로젝트: ullerrm/frogg
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);
    }
}
예제 #2
0
//-----------------------------------------------------------------------------------------------------------------------
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
예제 #3
0
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);
}
예제 #4
0
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;
}
예제 #5
0
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);
}
예제 #6
0
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;
}
예제 #7
0
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);
}
예제 #8
0
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;
}
예제 #9
0
// ---------------------------------------------------------------------------
// 
// ------------
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);
}
예제 #10
0
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;
}
예제 #11
0
//-------------------------------------------------------------------------------------------------------
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;
    }
}
예제 #13
0
// --------------------------------------------------------------------------------------
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;
}
예제 #14
0
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 );
}
예제 #15
0
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;
}
예제 #16
0
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;
}
예제 #17
0
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;
}
예제 #18
0
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;
}
예제 #19
0
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;
        }
    }
}
예제 #20
0
// --------------------------------------------------------------------------------------
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;
}
예제 #21
0
// ---------------------------------------------------------------------------
// 
// -----------
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;
}
예제 #23
0
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;
}      
예제 #24
0
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;
    }
}
예제 #25
0
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;
}
예제 #27
0
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));
}
예제 #28
0
파일: InfoWin.cpp 프로젝트: ullerrm/frogg
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;
}
예제 #29
0
파일: app.cpp 프로젝트: hgwells/tive
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 ;
}
예제 #30
0
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;
}