Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 88
Registered: ‎06-16-2012
My Device: N950/E7/N808/N9/X7/BB10 Alpha
My Carrier: Kievstar

Map screen coordinates to container's

How to convert screen coordinates from onTouch event to container;s coordinates? event.localX, event.localY, event.windowX, event.windowY, event.x, event.y returns same numbers..at least for scrollview container
Qt/Symbian/Meego/BB10/Cascades developer
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Map screen coordinates to container's

[ Edited ]

Hi! Not sure if this is the easiest way, but you can attach LayoutUpdateHandler to scrollView to obtain it's frame. Then store the frame in member variable and recalculate onTouch coordinates relative to it.

 

https://developer.blackberry.com/cascades/reference/bb__cascades__layoutupdatehandler.html

 

LayoutUpdateHandler::create(srollView)
    .onLayoutFrameChanged(this, SLOT(handleLayoutFrameUpdated(QRectF)));

 


Andrey Fidrya, @zmeyc on twitter
New Developer
Posts: 88
Registered: ‎06-16-2012
My Device: N950/E7/N808/N9/X7/BB10 Alpha
My Carrier: Kievstar

Re: Map screen coordinates to container's

Hi thanks for your answer I worked with layoutupdatehandle and this is probably some kind of solution, but I'm pretty sure, Local and window coordinates should do the job. If its not, its probably a bug?
Qt/Symbian/Meego/BB10/Cascades developer
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Map screen coordinates to container's

I've checked the objects hierarchy for ListView and seems no such mechanism exists yet. I wouldn't call this a bug but it could be convenient to have such methods. You might want to submit a feature request to issue tracker:

https://www.blackberry.com/jira/browse/BBTEN


Andrey Fidrya, @zmeyc on twitter
New Developer
Posts: 88
Registered: ‎06-16-2012
My Device: N950/E7/N808/N9/X7/BB10 Alpha
My Carrier: Kievstar

Re: Map screen coordinates to container's

thanks what about ScrollView?
Qt/Symbian/Meego/BB10/Cascades developer
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Map screen coordinates to container's

Sorry, I meant to say ScrollView. :smileyhappy:

Andrey Fidrya, @zmeyc on twitter
New Developer
Posts: 88
Registered: ‎06-16-2012
My Device: N950/E7/N808/N9/X7/BB10 Alpha
My Carrier: Kievstar

Re: Map screen coordinates to container's

ok, LayoutUpdateHandler doesnt works when zooming in scrollview, ie scale factor > 1
Qt/Symbian/Meego/BB10/Cascades developer