Using direct feedback

Direct feedback means that the application triggers feedback itself based on received pointer events. This approach is in general necessary in three cases:
  1. The triggering of feedback depends on the state of the control (or application) in such a way that the area registry cannot be used. For example: feedback is triggered from each new character when the user selects text with the stylus.
  2. Feedback area is non-rectangular and thus area registry cannot be used. For example: the user taps a tab of a non-focused view in a view-based application.
  3. Feedback is triggered from pointer repeat events.

Note: In the first two cases the feedback must be generated on the pointer down event, even though the related action itself would be done only on the pointer up event.

In a lot of cases, you may want to use both area registry based feedback and direct feedback in your application. In this case you must ensure these two do not overlap, so that direct feedback would be generated for some pointer events, which have already triggered feedback from the area registry.

Use the InstantFeedback function to generate direct feedback. This always causes a synchronous client-server transaction immediately. (If tactile feedback is not supported in the device, the API implementation ignores the function call.)

void CMyTactileEnabledControl::HandlePointerEventL(
    const TPointerEvent& aPointerEvent )
    {
    TBool stateChanged;

    // (your code here)

    if(aPointerEvent.iType == TPointerEvent::EDrag && stateChanged)
        {
        // Produce sensitive feedback when dragging causes a state
        // change (this kind of feedback triggering is not possible  
        // by using area registry).
        MTouchFeedback* feedback = MTouchFeedback::Instance();
        if ( feedback )
            {
            feedback->InstantFeedback( ETouchFeedbackSensitive );
            }
        }
    }

Also notice that there are two overloads of the InstantFeedback function: The first one only takes the logical feedback type as parameter, and can be used for generating feedback at any time, even when no UI controls are involved (for e.g. if the AppUi class wants to generate feedback). The second overload takes a CCoeControl pointer as parameter, and it does nothing in case feedback is disabled for the given control.

The latter overload is recommended to be used from UI controls, because that gives the owner of the control a possibility to disable both area registry based and direct feedback if needed.