Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2039] TextField.enabled and TextField.editable don't work

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionDuplicate
Resolution Date2012-07-20T13:53:05.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelstraining
ReporterPanMan
AssigneeNeeraj Gupta
Created2011-04-15T03:08:47.000+0000
Updated2017-03-21T23:13:19.000+0000

Description

I have a textfield with both enabled and editable set to false. However, when it's shown, it's still editable and enabled.
Code:

var tagcomment = Titanium.UI.createTextField({

value:'',
height:'35px',
width:300,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
top:100,
hintText: 'Enter a Tag',

clearButtonMode: Titanium.UI.INPUT_BUTTONMODE_ALWAYS,

editable: false,
enabled: false

}); tagview.add(tagcomment);

Comments

  1. wallneradam 2011-04-15

    I have the same problem on iPad.

  2. Stephen Tramer 2011-04-15

    Needs to be tested with permutations of editable/enabled; some of them are kind of ugly (e.g. editable=false;enabled=true).

  3. Dawson Toth 2011-04-15

    Associated Helpdesk Ticket

    http://developer.appcelerator.com/helpdesk/view/75801">http://developer.appcelerator.com/helpdesk/view/75801

  4. Dawson Toth 2011-04-15

    Sample Code for Testing All Permutations

       var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
       var scroll = Ti.UI.createScrollView({ layout: 'vertical' });
       win.add(scroll);
       
       scroll.add(Titanium.UI.createTextField({
           value:'Neither property, normal text field',
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Editable: false',
           editable: false,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Editable: true',
           editable: true,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Enabled: false',
           enabled: false,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Enabled: true',
           enabled: true,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Enabled: false + Editable: false',
           enabled: false,
           editable: false,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Enabled: true + Editable: true',
           enabled: true,
           editable: true,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Enabled: true + Editable: false',
           enabled: true,
           editable: false,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       scroll.add(Titanium.UI.createTextField({
           value:'Enabled: false + Editable: true',
           enabled: false,
           editable: true,
           height:35,
           right: 10,
           top: 10,
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
       }));
       
       win.open();
       
  5. Tony Lukasavage 2011-07-14

    I'm still having this issue as of sdk 1.7.1 for iphone
  6. Jeff Haynie 2011-07-14

    re-assigning for proper scheduling. this looks to be a regression?
  7. Tony Lukasavage 2011-08-02

    Still a problem in 1.7.2, at least for iPhone, haven't checked Android. I'm managing to work around it now with this:
     
       textField.addEventListener('focus', function(e) {
           e.source.blur();
       });
       
  8. Adam Wallner 2012-01-01

    It is still a problem in 1.8.0.1. It's in the documentation for ages that this property is supported on iPhone, but it has never been supported. I've created some modifications in TiUITextField.h and .m file, to implement this feature. Please include it into the next release. Thanks. *TiUITextField.h:*
       --- /Users/wallner/Library/Application Support/Titanium/mobilesdk/osx/1.8.0.1/iphone/Classes/TiUITextField.h	2011-12-23 12:03:47.000000000 +0100
       +++ /Users/wallner/Developer/Titanium/Studio/Scitec/build/iphone/Classes/TiUITextField.h	2012-01-02 08:04:42.000000000 +0100
       @@ -24,8 +26,11 @@
        	
        	BOOL becameResponder;
            NSInteger maxLength;
       +    
       +    BOOL editable;
        }
        
       +@property(nonatomic,readwrite,assign) BOOL editable;
        @property(nonatomic,readwrite,assign) CGFloat paddingLeft;
        @property(nonatomic,readwrite,assign) CGFloat paddingRight;
        @property(nonatomic,readwrite,assign) CGFloat leftButtonPadding;
       }}
       
    *TiUITextField.m:*
       --- /Users/wallner/Library/Application Support/Titanium/mobilesdk/osx/1.8.0.1/iphone/Classes/TiUITextField.m	2011-12-23 12:03:47.000000000 +0100
       +++ /Users/wallner/Developer/Titanium/Studio/Scitec/build/iphone/Classes/TiUITextField.m	2012-01-02 08:08:16.000000000 +0100
       @@ -18,6 +20,7 @@
        @implementation TiTextField
        
        @synthesize leftButtonPadding, rightButtonPadding, paddingLeft, paddingRight, becameResponder, maxLength;
       +@synthesize editable;
        
        -(void)configure
        {
       @@ -187,6 +190,7 @@
        	if ([super becomeFirstResponder])
        	{
        		[self repaintMode];
       +        if (!self.editable) [self resignFirstResponder];
        		return YES;
        	}
        	return NO;
       @@ -302,6 +306,12 @@
        	[[self textWidgetView] setEnabled:[TiUtils boolValue:value]];
        }
        
       +-(void)setEditable_:(id)editable
       +{
       +	[self textWidgetView].editable = [TiUtils boolValue:editable];
       +}
       +
       +
        -(void)setBackgroundImage_:(id)image
        {
        	UITextField *tf = [self textWidgetView];
       
  9. Neeraj Gupta 2012-07-21

    Duplicate of TIMOB-877.
  10. Lee Morris 2017-03-21

    Closing ticket as duplicate with reference to the above comments and links.

JSON Source