Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-996] Android: Text Field/Area needs hasText method

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-05-21T16:50:31.000+0000
Affected Version/sn/a
Fix Version/sSprint 2012-07, Release 2.0.1
ComponentsAndroid
Labelscore, qe-testadded, training
ReporterDon Thorp
AssigneeNeeraj Gupta
Created2011-04-15T02:41:08.000+0000
Updated2013-11-07T05:31:27.000+0000

Description

Comments

  1. Chase Culpepper 2012-03-23

    To test the fix for this, create a simple project that has the following code in app.js:
       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);
       
    After building and running the project, the log should read:
       I/TiAPI   (  441): [test] textArea1.hasText() = false
       I/TiAPI   (  441): [test] textArea2.hasText() = true
       I/TiAPI   (  441): [test] textArea3.hasText() = false
       I/TiAPI   (  441): [test] textField1.hasText() = false
       I/TiAPI   (  441): [test] textField2.hasText() = true
       I/TiAPI   (  441): [test] textField3.hasText() = false
       
  2. Dustin Hyde 2012-03-28

    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
  3. Michael Pettiford 2012-04-02

    Reopening/closing to add/remove labels
  4. Paul Dowsett 2012-05-06

    The test case provided in the comments above causes an exception on iOS and Android
  5. Paul Dowsett 2012-05-06

    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());
       });
       
  6. Allen Yeung 2012-05-21

    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.
  7. Satyam Sekhri 2012-07-16

    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
  8. Shameer Jan 2013-11-07

    Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4863

JSON Source