Beispiel #1
0
static pascal Boolean ErrorDlgFilterProc(DialogPtr theDialog, EventRecord *theEvent, short *theItemHit) {
    // We need this because this is a command-line application so it does not get normal events
    if (Button()) {
        *theItemHit = kStdOkItemIndex;
        return true;
    }
    
    return StdFilterProc(theDialog, theEvent, theItemHit);
}
Beispiel #2
0
/*	XOPDialogFilter(dialog, eventPtr, itemHitPtr)
	
	Handles the mapping of the enter key to the default button, the mapping
	of the escape key to the cancel button, and setting the cursor depending on
	the control under it. This requires that you previously called SetDialogDefaultItem,
	SetDialogCancelItem and SetDialogTracksCursor as shown in the sample XOPs.
	
	Also handles updating Igor windows if the dialog is moved. However, it does not
	update XOP windows.
	
	Thread Safety: XOPDialogFilter is not thread-safe.
*/
static pascal Boolean
XOPDialogFilter(DialogPtr theDialog, EventRecord *eventPtr, short *itemHitPtr)
{
	int callStdFilter;
	int result;

    result = 0;					// Means ModalDialog should handle the event.
    callStdFilter = 1;
    
    switch (eventPtr->what) {
    	case updateEvt:
    		if ((WindowPtr)eventPtr->message != GetDialogWindow(theDialog)) {
				// Mac OS X does the updating automatically, apparently using offscreen bitmaps.
    		}
    		break;
    	
    	case keyDown:
    		{
    			int keyCode = eventPtr->message & charCodeMask;		// Low order byte is character code.
    			switch(keyCode) {
    				case kHelpCharCode:
    					if (eventPtr->modifiers & optionKey) {
    						// option-help shows or hides Igor's contextual help window.
    						ShowHideContextualHelp(-1);
    						result = -1;							// We handled the event.
    						*itemHitPtr = 0;						// This is not a hit in any item.
    						callStdFilter = 0;
    					}
    					break;
    			}
    		}
    		break;
    }
    
    if (callStdFilter)
		result = StdFilterProc(theDialog, eventPtr, itemHitPtr);
	
	return result;
}