Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Event Handling Overview

Overview

Event handling in CPLAT_MacOS II is handled by registering for an event you want handled, and supplying a callback that gets called when the OS encounters that specific event.

Each object that is capable of handling events has a CP_EventHandler associated with that class that is responsible for maintining the interaction between the list of events that you want to be notified of, and the underlying OS.

In your class, you will want to register for the events you desire to handle as shown here:

        void CP_MyClass::InitEventHandler( CP_EventHandler& inEventHandler )
        {
                // install base events first in case we want to override them
            CP_BaseClass::InitEventHandler( inEventHandler );

                // install events for this class
            CP_EventSignal          *clickSignal = CP_new CP_EventSignal();
    
            clickSignal->connect( CPLAT_MacOS::CP_SigSlot::slot(this, &CP_MyClass::HandleMouseUp) );
            inEventHandler.Add( kCP_EventClassMouse, kCP_Event_MouseUp, clickSignal, GetOSControl() );
        }

Then whenever the user releases the mouse in your view, the method HandleMouseUp will be called.

Overriding Framework Events

If you have the desire or need to override an event that is handled by the CPLAT_MacOS framework, the process is easy. You simple need to call the Remove method of the objects event handler, then register your own handler as shown here.

        void CP_MyClass::InitEventHandler( CP_EventHandler& inEventHandler )
        {
                // install base events first in case we want to override them
            CP_BaseClass::InitEventHandler( inEventHandler );

                // first remove the existing mouse up handler
            inEventHandler.Remove( kCP_EventClassMouse, kCP_Event_MouseUp );

                // install events for this class
            CP_EventSignal          *clickSignal = CP_new CP_EventSignal();
    
            clickSignal->connect( CPLAT_MacOS::CP_SigSlot::slot(this, &CP_MyClass::HandleMouseUp) );
            inEventHandler.Add( kCP_EventClassMouse, kCP_Event_MouseUp, clickSignal, GetOSControl() );
        }

If you need to find out if a handler exists for the class, you can check with the HasHandler() method.


Generated on Tue Sep 20 20:22:25 2005 for CPLAT_MacOS by  doxygen 1.4.0