Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12293] BlackBerry: Implement View touch events (touchstart, touchmove, touchend, touchcancel)

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-05-22T18:39:16.000+0000
Affected Version/sRelease 3.3.0
Fix Version/sRelease 3.1.0, 2013 Sprint 02 BB, 2013 Sprint 02
ComponentsBlackBerry
Labelsblackberry, notable, qe-3.3.0, qe-testadded
ReporterJosh Roesslein
AssigneePedro Enrique
Created2013-01-15T21:48:04.000+0000
Updated2017-03-09T07:59:59.000+0000

Description

Implement the touch events for views.

Code to be tested

var win = Titanium.UI.createWindow({
	BackgroudColor:'white'
});

var view = Titanium.UI.createView({
	backgroundColor:'#669966',
	width:'90%',
	height:'94%',
	touchEnabled:'true'
});

var label = Ti.UI.createLabel({
	text:'FIRE AN EVENT :',
	top:20,
});

var l1 = Ti.UI.createLabel({
	text:'Touch Start Not Fired',
	top:60,
	left:0,
	width:'400',
	height:'auto',
	color:'#000',
	font:{fontFamily:'Helvetica Neue'}
});

view.addEventListener('touchstart',function(e){
	Ti.API.info('Touch Start fired');
	l1.color = 'red';
	l1.text = 'Touch Start Fired : x :' + e.x + '; y : ' + e.y;
	setTimeout(function()
		{
			l1.color = '#000';
		},200);
});

var l2 = Ti.UI.createLabel({
	text:'Touch Move Not Fired',
	top:90,
	left:0,
	width:'400',
	height:'auto',
	color:'#000',
});

view.addEventListener('touchmove',function(e){
	Ti.API.info('Touch Move fired');
	l2.color = 'red';
	l2.text = 'Touch Move Fired : x :' + e.x + '; y : ' + e.y;
	setTimeout(function()
		{
			l2.color = '#000';
		},200);
});

var l3 = Ti.UI.createLabel({
	text:'Touch Cancel Not Fired',
	top:120,
	left:0,
	width:'400',
	height:'auto',
	color:'#000',
});

view.addEventListener('touchcancel',function(e){
	Ti.API.info('Touch Cancel fired');
	l3.color = 'red';
	l3.text = 'Touch Cancel Fired : x :' + e.x + '; y : ' + e.y;
	setTimeout(function()
		{
			l3.color = '#000';
		},200);
});

var l4 = Ti.UI.createLabel({
	text:'Touch End Not Fired',
	top:150,
	left:0,
	width:'400',
	height:'auto',
	color:'#000',
});

view.addEventListener('touchend',function(e){
	Ti.API.info('Touch Cancel fired');
	l4.color = 'red';
	l4.text = 'Touch Cancel Fired : x :' + e.x + '; y : ' + e.y;
	setTimeout(function()
		{
			l4.color = '#000';
		},200);
});

view.add(label);
view.add(l1);
view.add(l2);
view.add(l3);
view.add(l4);
win.add(view);
win.open();

Comments

  1. Olga Romero 2014-05-21

    Touch Cancel works only.
  2. Pedro Enrique 2014-05-22

    PR: https://github.com/appcelerator/titanium_mobile_blackberry/pull/239 As a side note, the documentation states that "touchEnabled" takes a boolean as parameter, not a string like on the example. Changing it to a boolean would make this ticket invalid. The PR solves this by internally casting the string to a bool and making it fool-proof
  3. Lee Morris 2017-03-09

    Closing ticket as fixed.

JSON Source