//************************************************************************************** // Filename: NibAboutDialog.cp // Part of Contextual Menu Workshop by Abracode Inc. // http://free.abracode.com/cmworkshop/ // Copyright © 2002-2003 Abracode, Inc. All rights reserved. // // Description: classic about dialog, buttonless, modal, without window bar // dismissed by any click or key pressed // //************************************************************************************** // Revision History: // Saturday, June 7, 2003 - Original //************************************************************************************** #include "NibAboutDialog.h" void NibAboutDialog::InstallEventHandler() { const EventTypeSpec windowEvents[] = { { kEventClassMouse, kEventMouseDown }, { kEventClassKeyboard, kEventRawKeyDown } }; if ( mDlgEventHandlerUPP == NULL ) mDlgEventHandlerUPP = ::NewEventHandlerUPP( NibModalDialog::DialogEventHandlerProc ); OSStatus err = ::InstallWindowEventHandler( mWindow, mDlgEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, this, NULL ); } OSStatus NibAboutDialog::HandleEvent(EventHandlerCallRef inCallRef, EventRef inEvent) { #pragma unused (inCallRef) OSStatus err = eventNotHandledErr; UInt32 eventKind = GetEventKind( inEvent ); UInt32 eventClass = GetEventClass( inEvent ); if(eventClass == kEventClassMouse) { switch ( eventKind ) { case kEventMouseDown: { ::QuitAppModalLoopForWindow(mWindow); mIsRunning = false; err = noErr; } break; } } else if(eventClass == kEventClassKeyboard) { switch ( eventKind ) { case kEventRawKeyDown: { ::QuitAppModalLoopForWindow(mWindow); mIsRunning = false; err = noErr; } break; } } return err; }