Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios: uitextfield should resign responder #579

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/ios/YassViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void humanReadableByteCountBin(std::ostream* ss, uint64_t bytes) {
<< " " << *c;
}

@interface YassViewController () <UIPickerViewDataSource, UIPickerViewDelegate>
@interface YassViewController () <UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate>
- (NSString*)getStatusMessage;
@end

Expand All @@ -60,6 +60,11 @@ - (void)viewDidLoad {
[self.cipherMethod setDelegate:self];
[self.cipherMethod setDataSource:self];
[self.cipherMethod reloadAllComponents];
[self.serverHost setDelegate:self];
[self.serverPort setDelegate:self];
[self.username setDelegate:self];
[self.password setDelegate:self];
[self.timeout setDelegate:self];

[self LoadChanges];
[self UpdateStatusBar];
Expand All @@ -77,6 +82,28 @@ - (NSString*)getCipher {
return current_cipher_method_;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
if (textField == self.serverHost) {
if (textField.text.length > _POSIX_HOST_NAME_MAX) {
return NO;
}
}
if (textField == self.serverPort) {
auto port = StringToInteger(gurl_base::SysNSStringToUTF8(textField.text));
return port.has_value() && port.value() > 0 && port.value() < 65536 ? YES : NO;
}
if (textField == self.timeout) {
auto port = StringToInteger(gurl_base::SysNSStringToUTF8(textField.text));
return port.has_value() && port.value() >= 0 ? YES : NO;
}
return YES;
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
Expand Down
Loading