[TIMOB-8812] BlackBerry: Implement important Titanium.UI.Clipboard functionality
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-04-11T22:20:49.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 08 BB, 2013 Sprint 08, Release 3.2.0 |
Components | BlackBerry |
Labels | notable |
Reporter | Francois Boisvert |
Assignee | Josh Roesslein |
Created | 2012-04-20T09:48:00.000+0000 |
Updated | 2017-03-03T00:54:02.000+0000 |
Description
Implement the methods for accessing and modifying data within the clipboard.
Acceptance Test
// Custom application MIME types for clipboard data.
const kTypeText = 'application/x-text',
kTypeBlob = 'application/x-blob';
var win = Ti.UI.createWindow({
backgroundColor: 'red',
layout: 'vertical'
});
// Displays the current "plain text" in the clipboard.
var textLabel = Ti.UI.createLabel({
text: Ti.UI.Clipboard.getText() || "No text."
});
win.add(textLabel);
// Displays the current custom text in the clipboard.
var customTextLabel = Ti.UI.createLabel({
text: (Ti.UI.Clipboard.getData(kTypeText) || {text: 'No custom text.'}).text
});
win.add(customTextLabel);
// Displays the current custom blob data in the clipboard.
var customBlobLabel = Ti.UI.createLabel({
text: (Ti.UI.Clipboard.getData(kTypeBlob) || {text: 'No custom blob.'}).text
});
win.add(customBlobLabel);
// Clears all data in clipboard.
var clearDataButton = Ti.UI.createButton({
title: 'Clear Data'
});
clearDataButton.addEventListener('click', function() {
Ti.UI.Clipboard.clearData();
});
win.add(clearDataButton);
// Paste some text into the clipboard.
var setTextButton = Ti.UI.createButton({
title: 'Set Text'
});
setTextButton.addEventListener('click', function() {
Ti.UI.Clipboard.setText('Text Inserted!');
});
win.add(setTextButton);
// Paste custom application data into the clipboard.
var setCustomDataButton = Ti.UI.createButton({
title: 'Set Custom Data'
});
setCustomDataButton.addEventListener('click', function() {
Ti.UI.Clipboard.setData(kTypeText, 'Custom Text!');
var buffer = Ti.createBuffer({length: 16});
'Custom Blob!'.split('').forEach(function(char, index) {
buffer.fill(char.charCodeAt(0), index, 1);
});
Ti.UI.Clipboard.setData(kTypeBlob, buffer.toBlob());
});
win.add(setCustomDataButton);
win.open();
Closing ticket as Blackberry is no longer supported.