SDK 1.8.2
textarea竟然沒有支援hinttext…
(這個Titanium讓我有點看不懂了…
我一直以為他們是用JS模擬iOS SDK,現在看起來卻像是用自己的SDK為主找iOS中對應的部分套用?
希望SDK2能原生支援這些應該要有的的東西)
因此有人提出使用label作為替代的方法
http://developer.appcelerator.com/question/51081/hinttext-for-textarea
var value = "Whatever is going into the text area";
var hintText = "Notes";
var field = Ti.UI.createTextArea({
value: value,
color: 'blue'
});
var hint = Ti.UI.createLabel({
text: hintText,
color: 'gray',
textAlign: 'left',
left: '3%',
top: '20%',
height: '20%',
width: '100%',
backgroundColor: 'transparent',
touchEnabled: true
});
field.add(hint);
if (field.value.length > 0) {
hint.hide();
}
//*** Hint text appears when TextArea is blank, disappears when text is entered
field.addEventListener('change', function(e) {
if (e.source.value.length > 0) {
hint.hide();
} else {
hint.show();
}
});
//*** Make sure that TextArea gets focus if they tap the hint label
hint.addEventListener('click', function(e) {
field.focus();
});
//同場加映:避免textarea被觸發
- touchEnabled: false;
- captionText.addEventListener('focus', function(e)
- {
- //do nothing
- e.preventDefault();
- alert('test');
- });
沒有留言:
張貼留言