[TIMOB-12293] BlackBerry: Implement View touch events (touchstart, touchmove, touchend, touchcancel)
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-05-22T18:39:16.000+0000 |
Affected Version/s | Release 3.3.0 |
Fix Version/s | Release 3.1.0, 2013 Sprint 02 BB, 2013 Sprint 02 |
Components | BlackBerry |
Labels | blackberry, notable, qe-3.3.0, qe-testadded |
Reporter | Josh Roesslein |
Assignee | Pedro Enrique |
Created | 2013-01-15T21:48:04.000+0000 |
Updated | 2017-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();
Touch Cancel works only.
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
Closing ticket as fixed.