I want to select all text from the UITextField selected when i start editing. I tried the below code but this doesn't work.
[txt selectAll:self];
The HTMLInputElement. select() method selects all the text in a <textarea> element or in an <input> element that includes a text field.
On native platforms and browsers using a triple click (with a mouse) on text in a textfield one selects all text in the textfield.
Notice the use of JTextField 's getText method to retrieve the text currently contained by the text field.
TextField in Flutter is the most commonly used text input widget that allows users to collect inputs from the keyboard into an app. We can use the TextField widget in building forms, sending messages, creating search experiences, and many more. By default, Flutter decorated the TextField with an underline.
Please check where you have placed it... Try putting the code above in
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField selectAll:self];
}
And also txt must be UITextField. Also do not forget to set the delegate for txt as
txt.delegate = self;
where you have declared it and add UITextFieldDelegate in .h as
@interface ViewController : UIViewController <UITextFieldDelegate>
This will definitely work....It worked for me..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With