Clear text when edit or focus

Thread is closed for posting
2 posts, 0 answers
  1. Bhauvik T
    Bhauvik T avatar
    5 posts
    Member since:
    Dec 2009

    Posted 05 Apr Link to this post

    Could you please help me how to implement that function on TKDataFormTextFieldEditor ? What i need is the text field will be clear or empty when user click on that .

    Thanks. 

  2. Todor
    Admin
    Todor avatar
    798 posts

    Posted 11 Apr Link to this post

    Hello Bhauvik,

    Thank you for writing.

    Your requirement sounds like our hint text feature - this is a text which is visible while the value of the editor is nil. Here's an article which contains a snippet with the usage of hintText property. If this is not suitable and you really need to clear the text when the text field get the focus, you need to make your ViewController the delegate of the TextField which is part of the TKDataFormTextFieldEditor:

    -(void)dataForm:(TKDataForm *)dataForm setupEditor:(TKDataFormEditor *)editor forProperty:(TKEntityProperty *)property
    {
        if ([property.name isEqualToString:@"details"]) {
            TKTextField* tf = (TKTextField*)(editor.editor);
            tf.delegate = self;
        }
    }

    Then when the editor gets the focus, you will clear the text:

    - (void)textFieldDidBeginEditing:(UITextField *)textField {
        textField.text = nil;
    }

    I hope this information helps.

    Regards,
    Todor
    Telerik by Progress
    Want to build beautiful Android apps as well? Check out UI for Android which enables the same set of scenarios, allowing you to create the same great app experience on both iOS and Android.
Back to Top