Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created February 4, 2013 22:54
Show Gist options
  • Save alanleard/4710501 to your computer and use it in GitHub Desktop.
Save alanleard/4710501 to your computer and use it in GitHub Desktop.
Very simple drag and drop example
var win = Ti.UI.createWindow({
backgroundColor: '#333'
});
var box = Ti.UI.createView({
backgroundColor:'blue',
center:{x:50,y:50},
height:40,
width:40
});
win.add(box);
win.open();
box.addEventListener('touchmove', function(evt) {
var point = box.convertPointToView({ x: evt.x, y: evt.y }, win);
box.center = point;
});
box.addEventListener('touchend', function(evt){
var point = box.convertPointToView({ x: evt.x, y: evt.y }, win);
alert("x:"+point.x+" y:"+point.y);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment