Skip to content
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
74 changes: 74 additions & 0 deletions Ports/iOSPort/nativeSources/CodenameOne_GLViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,80 @@ void cn1_setStyleDoneButton(CN1_THREAD_STATE_MULTI_ARG UIBarButtonItem* btn) {
utv.text = [NSString stringWithUTF8String:str];
utv.delegate = [[CodenameOne_GLViewController instance] eaglView];

// Apply constraints for multiline text view
// INITIAL_CAPS_WORD
if((constraint & 0x100000) == 0x100000) {
utv.autocapitalizationType = UITextAutocapitalizationTypeWords;
} else {
// INITIAL_CAPS_SENTENCE
if((constraint & 0x200000) == 0x200000) {
utv.autocapitalizationType = UITextAutocapitalizationTypeSentences;
} else {
// UPPERCASE
if((constraint & 0x800000) == 0x800000) {
utv.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
} else {
utv.autocapitalizationType = UITextAutocapitalizationTypeNone;
}
}
}

// NON_PREDICTIVE
if((constraint & 0x80000) == 0x80000) {
utv.autocorrectionType = UITextAutocorrectionTypeNo;
}

// PASSWORD (Note: multiline password fields are uncommon, but supported)
if((constraint & 0x10000) == 0x10000) {
utv.secureTextEntry = YES;
if (@available(iOS 11, *)) {
utv.textContentType = UITextContentTypePassword;
}
}

if ((constraint & 0x400000) == 0x400000) {
if (@available(iOS 11, *)) {
utv.textContentType = UITextContentTypeUsername;
}
}

// EMAILADDR and other keyboard types (these apply even to multiline)
int cccc = constraint & 0xff;
if(cccc == 1) {
utv.keyboardType = UIKeyboardTypeEmailAddress;
utv.autocapitalizationType = UITextAutocapitalizationTypeNone;
if (@available(iOS 10, *)) {
utv.textContentType = UITextContentTypeEmailAddress;
}
} else {
// NUMERIC
if(cccc == 2) {
utv.keyboardType = UIKeyboardTypeNumberPad;
} else {
// PHONENUMBER
if(cccc == 3) {
utv.keyboardType = UIKeyboardTypePhonePad;
if (@available(iOS 10, *)) {
utv.textContentType = UITextContentTypeTelephoneNumber;
}
} else {
// URL
if(cccc == 4) {
utv.keyboardType = UIKeyboardTypeURL;
utv.autocapitalizationType = UITextAutocapitalizationTypeNone;
if (@available(iOS 10, *)) {
utv.textContentType = UITextContentTypeURL;
}
} else {
// DECIMAL
if(cccc == 5) {
utv.keyboardType = UIKeyboardTypeDecimalPad;
}
}
}
}
}

if(showToolbar) {
//add navigation toolbar to the top of the keyboard
#ifndef CN1_USE_ARC
Expand Down