BUG fix for CCEditBox setText not showing on loading

BUG fix for CCEditBox setText not showing on loading
0

#1

I found an issue where setting the text via setText() was not showing if I did this before tapping on the editbox and editing text. The issue is that setText() checks the textView’s hidden field which is “false” be default, but should be true. I fixed this be modding the initWithFrame: method of CCEditBoxImplIOS.m as follows:

-(id) initWithFrame: (CGRect) frameRect editBox: (void*) editBox
{
    self = [super init];

    do
    {
        if (self == nil) break;
        editState_ = NO;
        self.textField = [[[CustomUITextField alloc] initWithFrame: frameRect] autorelease];
        if (!textField_) break;
        [textField_ setTextColor:[UIColor whiteColor]];
        textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here.
        textField_.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        textField_.backgroundColor = [UIColor clearColor];
        textField_.borderStyle = UITextBorderStyleNone;
        textField_.delegate = self;
        textField_.returnKeyType = UIReturnKeyDefault;
        textField_.hidden = true; // +++ ADDED THIS LINE +++
        [textField_ addTarget:self action:@selector(textChanged) forControlEvents:UIControlEventEditingChanged];
        self.editBox = editBox;



        return self;
    }while(0);

    return nil;
}

Please integrate in to source.


#2

Thanks Justin!
I found the same problem today, and fixed it via you solution.


#3

Thanks Justin!
I found the same problem today, and fixed it via you solution.