[TIMOB-996] Android: Text Field/Area needs hasText method
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-05-21T16:50:31.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Sprint 2012-07, Release 2.0.1 |
| Components | Android |
| Labels | core, qe-testadded, training |
| Reporter | Don Thorp |
| Assignee | Neeraj Gupta |
| Created | 2011-04-15T02:41:08.000+0000 |
| Updated | 2013-11-07T05:31:27.000+0000 |
To test the fix for this, create a simple project that has the following code in app.js:
After building and running the project, the log should read:var textArea1 = Ti.UI.createTextArea(); var hasText = textArea1.hasText(); Ti.API.log('test','textArea1.hasText() = '+hasText); var textArea2 = Ti.UI.createTextArea({ value : 'I am a textarea', }); hasText = textArea2.hasText(); Ti.API.log('test','textArea2.hasText() = '+hasText); var textArea3 = Ti.UI.createTextArea({ value : '', }); hasText = textArea3.hasText(); Ti.API.log('test','textArea3.hasText() = '+hasText); var textField1 = Ti.UI.createTextField(); hasText = textField1.hasText(); Ti.API.log('test','textField1.hasText() = '+hasText); var textField2 = Ti.UI.createTextField({ value : 'I am a textfield' }); hasText = textField2.hasText(); Ti.API.log('test','textField2.hasText() = '+hasText); var textField3 = Ti.UI.createTextField({ value : '', }); hasText = textField3.hasText(); Ti.API.log('test','textField3.hasText() = '+hasText);Closing as Fixed. SDK: 2.1.0.v20120328100312 Android: V8, Rhino Studio: 2.0.0.201203271933 OS: Snow Leopard Devices Tested: Emulator 2.3.3
Reopening/closing to add/remove labels
The test case provided in the comments above causes an exception on iOS and Android
Test case
var win = Ti.UI.createWindow({ backgroundColor: 'white', exitOnClose: true, fullscreen: false, layout: 'vertical', title: 'hasText Demo' }); var textField = Ti.UI.createTextField({ color: '#336699', backgroundColor:'#eee', top: 10, left: 10, width: 250, height: 60, borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED }); win.add(textField); var textArea = Ti.UI.createTextArea({ borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED, backgroundColor:'#eee', color: '#336699', top: 10, left: 10, width: 250, height: 200 }); win.add(textArea); win.open(); textField.addEventListener('click', function(e){ Ti.API.info('hasText? ' + e.hasText()); }); textArea.addEventListener('click', function(e){ Ti.API.info('hasText? ' + e.hasText()); });The test case is actually invalid. The event object for click doesn't have a hasText() method. Instead, you should be using e.source.hasText(). I tested this on the lastest master build and it works correctly.
hasText method working on TextField/TextArea.Verified on: Titanium Studio: 2.1.1.201207121732 Titanium SDK: 2.1.1.v20120712160111 Android: V8 Device: Emulator2.2
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4863