Android Question Android App on Chromebook ignores Uppercase field

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I have a modified version of this TextInputBox code https://www.b4x.com/android/forum/threads/b4x-textinputbox.129654/#content

B4X:
Private Sub TextInputBox(Prompt As String, DefaultText As String, MinLength As Int, MaxLength As Int, CaseType As String, ExtraChars As String) As ResumableSub
            Dim ReturnedValue     As String = ""

            Dim Dialog             As B4XDialog
            Dim InputTemplate     As B4XInputTemplate
            
            Dialog.Initialize(Root)
            Dialog.BackgroundColor    = Colors.Blue    '0xFF4682B4        ' Steel Blue
            Dialog.BorderColor        = Colors.White
            Dialog.ButtonsColor        = Colors.Black
            Dialog.ButtonsTextColor = Colors.White

            InputTemplate.Initialize

            InputTemplate.lblTitle.Text         = Prompt
            InputTemplate.lblTitle.TextColor    = Colors.White
            InputTemplate.lblTitle.TextSize        = 20

            
            InputTemplate.Text                     = DefaultText    
            InputTemplate.SetBorderColor(Colors.White, Colors.White)
            #if B4A
            InputTemplate.TextField1.Font        = xui.CreateFont(Typeface.DEFAULT_BOLD, InputTemplate.TextField1.TextSize)
            #else if B4i
            InputTemplate.TextField1.Font        = xui.CreateFont(Font.DEFAULT_BOLD, InputTemplate.TextField1.TextSize)
            #end if
            

            
            Dim RegexPattern         As String
            Dim PatternLetterCase     As String

            CaseType = CaseType.ToUpperCase
                        
            Select     CaseType
                    Case     "L"
                            PatternLetterCase = "a-z"
                            
                    Case     "U"
                            PatternLetterCase = "A-Z"
                            
                    Case     "B"
                            PatternLetterCase = "a-zA-Z"
                            
                    Case     "#"                            
                            PatternLetterCase = "A-Z0-9"                                                
            End Select

            #if B4A
            Dim et As EditText = InputTemplate.TextField1
            #else if B4I
            Dim et As TextView = InputTemplate.TextField1
            #end if

            If  CaseType = "U" Or CaseType = "#"  Then                                    
                et.InputType     = Bit.Or(et.InputType, cBBsGlobals.TYPE_TEXT_FLAG_CAP_ALL)     ' this is value  0x00001000  4096
                et.Padding        = Array As Int(10dip, 0, 0, 0)            
            End If
            
            If  DefaultText.Length > 0 Then
                et.SelectAll
            End If
            
            If     ExtraChars.Length > 0 Then
                ExtraChars = Regex.Replace("([a-zA-Z0-9])", ExtraChars, "")
                
                If     ExtraChars.Length > 0 Then
                    If     Not(ExtraChars.StartsWith("\")) Then
                        ExtraChars = "\" & ExtraChars
                    End If
                    
                    PatternLetterCase = PatternLetterCase & ExtraChars
                End If
            End If

            RegexPattern = $"[${PatternLetterCase}]{${MinLength},${MaxLength}}"$

            InputTemplate.RegexPattern = RegexPattern

            Wait For (Dialog.ShowTemplate(InputTemplate, "OK", "", "Cancel")) Complete(Result As Int)

            If     Result = xui.DialogResponse_Positive Then
                ReturnedValue = InputTemplate.Text
            End If

            Return ReturnedValue.ToUpperCase
End Sub

I call it like this:
B4X:
            Wait For (TextInputBox("BBs Standing UpLoad ID", mLastNotFound_UpLoadID, 3, 15, "#", "")) Complete(UpLoadID As String)

Works great on EVERYTHING I try except a Chromebook.

Chromebook does not put Uppercase characters in unless I hold down the shift key or do a Alt-Search key to turn on cap locks.

I even tried forcing on uppercase by setting InputType

Strange behavior

Any ideas on how to get a field to be only Uppercase and Numbers

BobVal
 
Top