Capturing key events using Animation dll
An animation DLL defines a framework for polymorphic DLLs that perform animations. However, it can also be used to get the raw window server events.
This article provides an additional aspect of capturing raw events using an animation DLL. The animation example already present in S60 examples does not include code for raw event handling.
All the raw events can be received and handled in MEventHandler::OfferRawEvent(). This function is implemented in an CAnim-derived class. This function should return EFalse, otherwise the foreground application or applications that have registered to get key events using RWindowGroup::CaptureKey() will not receive them.
TBool CImage::OfferRawEvent( const TRawEvent& aRawEvent )
// To capture Zero key press
if(aRawEvent.Type()==TRawEvent::EKeyDown && aRawEvent.ScanCode()=='0')
// Event handling code
These events are offered to MEventHandler::OfferRawEvent() only if raw event handling is switched on. This is done by calling MAnimGeneralFunctions::GetRawEvents(ETrue). An object of class MAnimGeneralFunctions is not created. The class is implemented by the window server and provides utility functions to all CAnim-derived classes via CAnim::iFunctions pointer. So in order to receive raw events, add the following code to ConstructL of the CAnim-derived class:
void CImage::ConstructL( TAny* /*aArgs*/, TBool /*aHasFocus*/ )