语言

Menu
Sites
Language
How to get TOUCH position on CustomItem?

Hi all,

How to get TOUCH position on CustomItem in ListView?

响应

2 回复
Chintan Gandhi

Hi Sergei Melikhov,

While adding an element in CustomItem you should already know the rectangle parameters for that element so anywhere clicked within the rectangle triggers the event.:)

Thanks.

Alex Dem

Hi ,
I did not find good way ( I could not add TouchEventListener for separate custom Item in List , only for whole List).

But if your List is not scrollable and sizes are known you could use this approach with using of  Tizen::Ui::ITouchEventListener interface:

1) At first please add touch event listener for your ListView:
__pListView->AddTouchEventListener(*this);
2) After this you are able to get coordinates of pressed point in List and extract appropriate item index this way:

OnTouchPressed (..)
{
        int index =__pListView->GetItemIndexFromPosition(currentPosition.x,currentPosition.y);
        AppLog("OnTouchPressed=%d %d",currentPosition.x, currentPosition.y);
        AppLog("OnTouchPressed=%d", index);
}

3) You could calculate relative position inside of now pressed item.
Alexey.