Last Updated: February 25, 2016
· himade

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

var convertedPoint = self.convertPointToView({x: e.x, y: e.y}, mainWindow);; = 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
var view = new createView;
});// End of Button Event Listener

mainWindow.add(btn); //Add the btn to main window; //Open the main window