Storing and retrieving data via the clipboard
The clipboard is used to store textual and object data so that it can be utilized between different screens and applications on your device. While both iOS and Android have a built-in clipboard capability, Titanium extends this by letting you programmatically access and write data to the clipboard. In this recipe, we will create a screen with two text fields and a series of buttons that allow us to programmatically copy data from one text field and paste it to another.
How to do it…
Open your project's
app.js
file and enter the following text (deleting any existing code). Once you are done, run your application on the simulator to test it:var win1 = Ti.UI.createWindow({ backgroundColor : '#fff', title : 'Copy and Paste' }); var txtData1 = Ti.UI.createTextField({ left : 20, width : 280, height : 40, top : 40, borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED }); var txtData2 = Ti.UI.createTextField({ left : 20, width : 280, height...