Appcelerator Drag and Drop - 35 LOC
Put the code in a blank app.'s file
//Create Main Window - App.js
var mainWindow = Ti.UI.createWindow({
backgroundColor: 'white'
});
//Function to create views that can be dragged and dropped!
function createView(){
var self = Ti.UI.createView({
backgroundColor: 'red',
height: '25dp',
width: '25dp'
});//End of createView Function
self.addEventListener('touchmove',function(e){
var convertedPoint = self.convertPointToView({x: e.x, y: e.y}, mainWindow);
Ti.API.info(convertedPoint);
self.center = convertedPoint;
});// View Event Listener
return self; //Return the view as a constructor
};
//Button to add View
var btn = Ti.UI.createButton({
title: 'add view',
bottom: 10,
right: 10
});
//Button Event Listener
btn.addEventListener('click',function(){
var view = new createView;
mainWindow.add(view);
});// End of Button Event Listener
mainWindow.add(btn); //Add the btn to main window
mainWindow.open(); //Open the main window