Upper Text

Mahares

Expert
Licensed User
Longtime User
Here is another option that yo can compare and choose the one more suitable for your needs as there are more ways to skin a cat:
If you have a few edittext boxes assign them all the same event name. Call it MyEdit, then copy the below sub in your code. When you lose focus and more from control to the other, the text changes to upper case even if you are typing it in lower case.:
B4X:
Sub MyEdit_FocusChanged(Hasfocus As Boolean)
         Dim Send As EditText
         Send=Sender
          If Hasfocus=False Then
            Send.text=Send.text.ToUpperCase
         End If
End Sub
If you are dealing say with one edittext view txtABC, you can do this:

B4X:
Sub txtABC_FocusChanged(Hasfocus As Boolean)
         If Hasfocus=False Then
            txtABC.text=txtABC.text.ToUpperCase
         End If
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I wrote this code Activity_Create, It did not work
What code did you write ?
Did you replace edittext1 by the name of your EditText view.

The code below works !
B4X:
Sub Globals
    Dim ckbUpperCase As CheckBox
    Dim edtTest1, edtTest2 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    edtTest2.InputType = Bit.Or(edtTest2.INPUT_TYPE_TEXT , 4096) 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ckbUpperCase_CheckedChange(Checked As Boolean)
    If Checked = True Then
        edtTest1.InputType = Bit.Or(edtTest1.INPUT_TYPE_TEXT , 4096) 
    Else
        edtTest1.InputType = edtTest1.INPUT_TYPE_TEXT
    End If
End Sub
In test program you can check or uncheck UpperCase mode.

Best regards.
 

Attachments

  • EditTextUpperCase.zip
    6.6 KB · Views: 167
Upvote 0

Neojoy

Member
Licensed User
Longtime User
Thank Klaus, but in phone the first char is showed in uppercase and I would like to force all chars in lower case on the fly
 
Upvote 0
Top