zoukankan      html  css  js  c++  java
  • How_to_Handle_Pointer_Events_in_a_Custom_Control(转)

    This page was last modified on 30 September 2009, at 06:05.

    ID...Creation date26.10.2008
    PlatformS60 5th EditionTested on devicesNokia 5800 XpressMusic.
    CategorySymbian C++SubcategoryTouch UI

    Keywords (APIs, classes, methods, functions): HandlePointerEventL(),Custom Control.

    Overview

    This snippet shows how to handle Pointer events in a custom control and route them to a proper component control by validating the pointer area against the control rect.

    This snippet can be self-signed.

    Preconditions

    Here we assume that we already have a working code for custom control, and we also assume that we have two components: iEdwin1 and iEdwin2 in a custom control.

    MMP file

    The following capabilities and libraries are required:

    CAPABILITY  None
     
    LIBRARY cone.lib

    #include <COECNTRL.H> 
     
    void CCustomContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    // Validate pointer position.
    if( iEdwin1->Rect().Contains( aPointerEvent.iPosition ) )
    {
    // click on edwin1 pass the pointer event. //
    iEdwin1->HandlePointerEventL( aPointerEvent );
    }
    else if( iEdwin2->Rect().Contains( aPointerEvent.iPosition ) )
    {
    // click on edwin2 pass the pointer event. //
    iEdwin2->HandlePointerEventL( aPointerEvent );
    }
    else
    {
    // simply calling the base class implementation //
    CCoeControl::HandlePointerEventL(aPointerEvent);
    }
    }

    Postconditions

    Pointer position will validated against the control rectangle and the pointer events will be routed to appropriate control.

  • 相关阅读:
    MJExtension的使用
    Swift
    2月22号 UITableView
    1月25号 CALayer
    1月22号 animation—1
    1月22号 KVC KVO
    2016.01.22 简单动画
    2016.01.22 KVC&KVO
    2016.01.22 单例模式(Singleton)
    2016.01.21 UITabBarController
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/1906473.html
Copyright © 2011-2022 走看看