Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10030] TiAPI: "click" event produces wrong coordinates

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-04-25T10:20:09.000+0000
Affected Version/sRelease 2.1.0
Fix Version/s2013 Sprint 09
ComponentsAndroid
Labelsapi, community
ReporterIvan Skugor
Assigneejithinpv
Created2012-07-15T05:20:58.000+0000
Updated2017-03-17T18:46:40.000+0000

Description

The problem

"click" event produces wrong "x" and "y" coordinates.

Steps to reproduce

To see the issue, run this example:
var win = Ti.UI.createWindow({
    backgroundColor: '#000',
    navBarHidden: true
});

var wrapper = Ti.UI.createView({
	height: 20,
	backgroundColor: '#f00',
	width: 200
});

var left = Ti.UI.createView({
	height: 10,
	width: 200,
	left: 0,
	backgroundColor: '#093',
	width: 0
});

var right = Ti.UI.createView({
	height: 10,
	width: 0,
	right: 0,
	backgroundColor: '#039',
	width: 200
});

wrapper.add(left);
wrapper.add(right);
win.add(wrapper);

wrapper.addEventListener('click', function(e) {
	var x = e.x.toFixed(2);
	Ti.API.info('x: ' + x);
	left.width = x;
	right.width = 200 - x;
});

win.open();
Click on red view from left to right. First few clicks work fine, but after the values are wrong. That can be seen in the console output, but also visually (by width of two inner views). The issue exists on Android and on iOS.

Comments

  1. Ivan Skugor 2012-07-20

    I have some more info regarding this issue. It seems that issue is not present when there is only one view inside "wrapper" (and that is, "left" view) and the issue is caused by "right" view. The workaround is to set "touchEnabled" to "false" to "right" view. I guess that "right" view somehow captures "click" and sends wrong coordinates to its parent view. Also, that works very strangely because numbers returned are alternating between two values when user clicks at same point.
  2. jithinpv 2013-04-25

    cannot reproduce Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Android Emulator: Android SDK version: 2.2
  3. Lee Morris 2017-03-17

    Closing ticket as the issue cannot be reproduced.

JSON Source