Titanium JIRA Archive
Appcelerator Community (AC)

[AC-774] get screen coordinates - convertPointToView - not requested view

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-09-17T06:53:43.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsStudio
Labelsandroid, drag, ios, slide
ReporterRicardo Pereira
AssigneeShak Hossain
Created2014-09-23T18:34:06.000+0000
Updated2016-03-08T07:37:02.000+0000

Description

When I'm trying to get the slided coordinates, if I start the touch in another view it gets its positions instead the requested one. See the exemple, start sliding in the red or blue box, and see the console logs.

Attachments

FileDateSize
touch_e.png2014-09-24T13:51:28.000+000016209
touchmove.bug.exemple.zip2014-09-23T18:34:06.000+00003369788

Comments

  1. Ricardo Pereira 2014-09-24

    I've figured out: var real_screen_coords = { x:0, y:0 }; app_window.addEventListener("touchmove",function(e) { real_screen_coords = e.source.convertPointToView({ x : e.x, y : e.y }, app_window); });
  2. Ricardo Pereira 2014-09-24

    I am trying to get the coordinates of the main window using touchstart event: win.addEventListener("touchstart", function(e) { console.log(e.x); }); But if i'm touching a view or label inside the window, it gives the views/labels coordinates, how can I bypass that, in order to get only the main window coordinates?
  3. Ricardo Pereira 2014-09-24

    touch events logs
  4. Papia Chowdhury 2015-09-07

    Hello, We tested this issue and found out that the convertPointToView works as expected. Please check out the sample we tested here and let us know if you notice otherwise. *Testing Environment:* Appcelerator Studio, build: 4.2.0.201508141038 Titanium SDK: 4.1.0 GA iOS simulator: iphone 5s(v8.1) OS X version: 10.9.5 *Steps to Test:* 1. Create a classic project 2. Copy below code and run the app Now, click on any point and observe that the x and y coordinate of main window shown in the log. *Test Case:* app.js
       var win = Ti.UI.createWindow({
       	backgroundColor : 'black'
       });
       var center1 = {
       	'x' : 100,
       	'y' : 100
       };
       var center2 = {
       	'x' : 100,
       	'y' : 250
       };
       var lastIndex = 1;
       var background = Ti.UI.createView({
       	backgroundColor : "#444444",
       });
       var view = Ti.UI.createView({
       	backgroundColor : 'red',
       	center : center1,
       	width : 100,
       	height : 100,
       	zIndex : lastIndex++,
       });
       var view2 = Ti.UI.createView({
       	backgroundColor : 'green',
       	center : center2,
       	width : 100,
       	height : 100,
       	zIndex : lastIndex,
       });
       background.addEventListener('touchstart', function(e) {
       	var bgPoint = background.convertPointToView(e, background);
       	Ti.API.info("Background Point: " + bgPoint.x + "," + bgPoint.y);
       	view.center = bgPoint;
       	view.backgroundColor = 'blue';
       });
       
       view.addEventListener('touchend', function(e) {
       	view.center = center1;
       	view.backgroundColor = 'red';
       });
       win.add(background);
       win.add(view);
       win.add(view2);
       win.open(); 
       
    Thanks.

JSON Source