B4A Library [B4X] SD CustomKeyboard


THIS version is no longer updated and supported. You can continue to use it if you want.
Or try the
new version with rewritten methods and new features

IMPORTANT
  • depends on SD CreativeBackGround (0.06+) library which must be downloaded
  • MaterialIcon font for special characters must be loaded.
    Use: SD_Keyboard1.SpecialKeyFont = xui.CreateMaterialIcons (16)

SD_CustomKeyboard

Author:
Star-Dust
Version: 1.20
  • CustomKey
    • Fields:
      • CodeCanc As Int
      • CodeDel As Int
      • CodeEnter As Int
      • CodeEraseAll As Int
      • CodeEsc As Int
      • CodeNext As Int
      • CodeShift As Int
      • CodeTab As Int
    • Functions:
      • AddCustomKeyToLastRow (UpperText As String, UpperCode As Int, LowerText As String, LowerCode As Int, size As Int, BackgroundKeyColor As Int, TextKeyColor As Int) As String
        Ck.AddCustomKeyToLastRow("SPACE",32,"SPACE.",32,3,xui.Color_Red,xui.Color_White) ' space large 3 key
        Ck.AddCustomKeyToLastRow("Enter",ck.CodeEnter,"Enter",ck.CodeEnter,1, ,xui.Color_Green,xui.Color_White))
      • AddDoubleCharToLastRow (Keys As String()) As String
        Char or key: Shift, Canc, Del, Tab, Esc, Next,EraseAll
        CustomKey.AddRowDoubleCharToLastRow(array as string("Aa","Bb","Cc","Next","Tab","Canc"))
        CustomKey.AddRowDoubleCharToLastRow(Regex.Split(",","Aa,Bb,Cc,00,11,12,Enter"))
      • AddEmptyRow As String
      • AddEmptySpaceToLastRow As String
      • AddKeyToLastRow (UpperText As String, UpperCode As Int, LowerText As String, LowerCode As Int, size As Int) As String
        Ck.AddKeytoLastRow("SPACE",32,"SPACE.",32,3) ' space large 3 key
        Ck.AddKeytoLastRow("",0,"",0,1) ' Empty
        Ck.AddKeytoLastRow("Enter",ck.CodeEnter,"Enter",ck.CodeEnter,1)
      • AddRow (Keys As List) As String
        CustomKey.AddRow(ListOfSingleKey)
      • AddRowDoubleChar (Keys As String()) As String
        Char or key: Shift, Canc, Del, Tab, Esc, Next,EraseAll
        CustomKey.AddRowDoubleChar(array as string("Aa","Bb","Cc","Next","Tab","Canc"))
        CustomKey.AddRowDoubleChar(Regex.Split(",","Aa,Bb,Cc,00,11,12,Enter"))
      • AddRowSimpleChar (Keys As String()) As String
        Char or key: Shift, Canc, Del, Tab, Esc, Next, EraseAll
        CustomKey.AddRowSimpleChar(array as string("A","B","C","Next","Tab","Canc"))
        CustomKey.AddRowSimpleChar(Regex.Split(",","A,B,C,0,1,2,Enter"))
      • AddRowStringtoKey (Strings As String()) As String
        Don't insert special char: Shift, Canc, Del, Tab, Esc, Next
        CustomKey.AddRowStringtoKey(array as string("00","000","Hallo"))
        CustomKey.AddRowStringtoKey(Regex.Split(",","00,000,Hallo"))
      • AddSimpleCharToLastRow (Keys As String()) As String
        Char or key: Shift, Canc, Del, Tab, Esc, Next, EraseAll
        CustomKey.AddSimpleCharToLastRow(array as string("A","B","C","Next","Tab","Canc"))
        CustomKey.AddSimpleCharToLastRow(Regex.Split(",","A,B,C,0,1,2,Enter"))
      • cEmptyKey As Type_SingleKey
      • cKey (UpperText As String, UpperCode As Int, LowerText As String, LowerCode As Int) As Type_SingleKey
      • cKeyCustomized (UpperText As String, UpperCode As Int, LowerText As String, LowerCode As Int, size As Int, BackgroundKeyColor As Int, TextKeyColor As Int) As Type_SingleKey
      • cKeySized (UpperText As String, UpperCode As Int, LowerText As String, LowerCode As Int, size As Int) As Type_SingleKey
      • Class_Globals As String
      • Initialize As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • KeyBoard As List
  • SD_Keyboard
    • Fields:
      • InsertAlwaysAtEnd As Boolean
      • keyCanc As String
      • keyDel As String
      • keyEnter As String
      • keyEraseAll As String
      • keyNext As String
      • keyShiftDown As String
      • keyShiftLock As String
      • keyShiftUp As String
      • KeyStyle As Int [write only]
        0-Standard; 1-Comics; 2-Heart; 3-Flower; 4-Octagon
      • keyTab As String
      • mBase As B4XView
      • Tag As Object
      • TimeLapseMilliSec As Int
    • Functions:
      • Add (TextEditorView As B4XView, NativeEventName As String, CustomizeKeyboard As CustomKey, NextFocus As B4XView) As String
        --------------------------------- aggiuntivi ------------------------------------
      • Add2 (TextEditorView As B4XView, NativeEventName As String, CustomizeKeyboard As CustomKey, ShiftOn As Boolean, NextFocus As B4XView) As String
      • Class_Globals As String
      • ClearKeyboard As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • DrawKeyboard (V As B4XView) As String
      • GetBase As B4XView
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • SetEvent (View As EditText, te As TypeED) As String
      • SetupColor (BackgroundColorKey As Int, TextColorKey As Int, BackgroundColorBoard As Int)
      • ShifOn (S As Boolean) As String
      • ShiftStatus As Boolean
      • Snapshot As B4XView
    • Properties:
      • DarkFactor As Float
        To set the intensity of the dark part of the shadow - normally = 0.85
      • Font
        Set Key Font
      • Height As Int
      • ImageBackground
      • Left As Int
      • LightFactor As Float
        To set the intensity of the light part of the shadow - normally = 1.15
      • ShowKeyboard As Boolean
      • SpecialKeyFont
        Set Font of SpecilKey - Standard: MaterialIcon
      • Top As Int
      • Visible As Boolean
      • Width As Int


____________________________________________________________________________________________________________________________________________________



B4A, B4J, B4I
1644858933600.png
1644858999113.png
1644859187138.png
1651651351138.png
1651651416509.png
1651651497482.png



log release
  • 1.03
    Added AddRowDouble method: allows you to enter the value in uppercase and lowercase for each key, for keys with special characters you can establish the character that will show in normal and with the shift
  • 1.04
    Added ClearKeyboard method to clear the keyboard with all the associations made with the views
    Added AddRowStringtoKey method that allows you to associate a complex key with multi-character text. With this method it is not possible to set special keys such as Shift, Canc, Del, Tab, Esc, Next.
  • 1.05
    Added Vibration option in design
  • 1.06
    Added new Key: EraseAll. Delete all text in the field
    Added: LightFactor and DarkFactor property
  • 1.07
    Now the special keys are created with the MaterialIcons font.
    It will be possible to change the font of the special characters and the text of the characters
    We have updated all the examples with the addition of the MaterialIcons font and added all the missing iOs examples
  • 1.08
    Customized keys with the possibility of establishing their size
    Ability to customize the background with an image
    Possibility to insert empty spaces between the keys
    Possibility to set the StartSelect always at the end
  • 1.09
    Added AddSimpleCharToLastRow and AddRowDoubleCharToLastRow methods.
    Added constants with the numeric code of the special keys: CodeCanc,CodeTab,CodeEnter,CodeEsc,CodeDel,CodeNext,CodeShift,CodeEraseAll
    Ability to add custom keys that raise an event other than TextChange
    Added new event to TextField or EditText view to handle custom keys that can have a negative value return code. Example: TextField1_CustomKey (Code As Int)
  • 1.10; 1.11
    Fix bugs
  • 1.12
    Added AddCustomKeyToLastRow method in CustomKey class to customize single key colors
    Added Add2 method in the SD_Keyboard class to set the SHIFT key when starting the keyboard
  • 1.13
    Set Shift key by code
    Fix bugs
  • 1.14
    Added AddEmptyKeyToLastRow method in CustomKey class
    Added cEmptyKey method in CustomKey class
  • 1.15
    Added AddEmptyRow method in CustomKey class
  • 1.16
    Fixed BUGS that gave false warning for missing MaterialIncons font
  • 1.17
    Updated to work with version 0.6 of SD_CreativeBackGround
  • 1.18
    Added the SetupColor method to change the color of the background, buttons and text from code
  • 1.19
    Added KeyStyle property
  • 1.20
    Fix bug

Important depends on SD CreativeBackGround library which must be downloaded
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Sample 1

Main
Main:
    Dim Ck As CustomKey
    Ck.Initialize
    Ck.AddRowSimpleChar(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P"))
    Ck.AddRowSimpleChar(Regex.Split(",","A,S,D,F,G,H,J,K,L,Canc"))
    Ck.AddRowSimpleChar(Regex.Split(",","Z,X,C,V,B,N,M,Next" ))
 
    SD_Keyboard1.Add(TextField1,"TextField1",Ck,TextField2)
  
    Dim Ck As CustomKey
    Ck.Initialize
    Ck.AddRowSimpleChar(Regex.Split(",","1,2,3,4,5,6,7,8,9,0,?"))
    Ck.AddRowSimpleChar(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P,Canc" ))
    Ck.AddRowSimpleChar(Regex.Split(",","A,S,D,F,G,H,J,K,L,Del"))
    'Ck.AddRowSimpleChar(Regex.Split(",","Z,X,C,V,B,N,M,Enter"))
 
    Dim L As List
    L.Initialize
    L.Add(Ck.cKey("Z",90,"z",122))
    l.Add(Ck.cKey("X",90,"x",122))
    L.Add(Ck.cKey("C",67,"c",99))
    l.Add(Ck.cKey("V",86,"v",118))
    l.Add(Ck.cKey("B",66,"b",98))
    l.Add(Ck.cKey("N",78,"n",110))
    L.Add(Ck.cKey("M",77,"m",109))
    l.Add(Ck.cKey("ENTER",13,"enter",13))
    Ck.AddRow(L)
 
    SD_Keyboard1.Add(TextField2,"TextField2",Ck,TextField1)

Event
B4X:
Private Sub TextField1_FocusChanged (HasFocus As Boolean)
    Log("Focus1: " & HasFocus)
End Sub

Private Sub TextField2_FocusChanged (HasFocus As Boolean)
    Log("Focus2: " & HasFocus)
End Sub

Private Sub TextField1_EnterPressed
    Log("Enter 1")
End Sub
Private Sub TextField2_EnterPressed
    Log("Enter 2")
End Sub

Private Sub TextField2_TextChanged (Old As String, New As String)
    Log("Change: " & Old & " " & New)
End Sub

1.gif
 

Attachments

  • aSample1.zip
    9.1 KB · Views: 465
  • iSample1.zip
    3.2 KB · Views: 369
  • jSample1.zip
    2.7 KB · Views: 409
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Sample 2

1644872677853.png
 

Attachments

  • aSample2.zip
    8.9 KB · Views: 438
  • iSample2.zip
    3.2 KB · Views: 357
  • jSample2.zip
    2.6 KB · Views: 365
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Sample 3 - Sample 4 - Sample 5

3.gif
1645088017703.png
1645087986839.png
 

Attachments

  • aSample3.zip
    8.9 KB · Views: 411
  • iSample3.zip
    3.1 KB · Views: 353
  • jSample3.zip
    2.6 KB · Views: 386
  • aSample4.zip
    52.7 KB · Views: 393
  • iSample4.zip
    3.1 KB · Views: 372
  • jSample4.zip
    46.4 KB · Views: 361
  • aSample5.zip
    8.8 KB · Views: 438
  • iSample5.zip
    18.8 KB · Views: 355
  • jSample5.zip
    2.4 KB · Views: 376
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
How to customize special keys
B4X:
' Before setting up the keyboard with SD_Keyboard.Add
SD_Keyboard1.keyShiftUp = "↑"
SD_Keyboard1.keyShiftDown = "↓"
SD_Keyboard1.keyShiftLock = "▲"
SD_Keyboard1.keyCanc = "←"
SD_Keyboard1.keyDel = "׀←"
SD_Keyboard1.keyTab = "׀→׀"
SD_Keyboard1.keyNext = "Next"
SD_Keyboard1.keyEnter = "◄┘"
 

Star-Dust

Expert
Licensed User
Longtime User
I'm sorry I thought you included it in the library

 

incendio

Well-Known Member
Licensed User
Longtime User
Tried Example 1 on Android 9 emulator, got an error :
sd_keyboard_class_globals (java line: 291)
java.lang.NoClassDefFoundError: Failed resolution of: Lb4a/example/shadoweffectbackground;
 

Star-Dust

Expert
Licensed User
Longtime User
Tried Example 1 on Android 9 emulator, got an error :
sd_keyboard_class_globals (java line: 291)
java.lang.NoClassDefFoundError: Failed resolution of: Lb4a/example/shadoweffectbackground;
As already written it depends on the SD_CreativeBackground library, you can download it from here

 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 1.03
  • Added AddRowDouble method: allows you to enter the value in uppercase and lowercase for each key, for keys with special characters you can establish the character that will show in normal and with the shift
  • fix bugs
B4X:
Ck.AddRowDoubleChar(Regex.Split(",","Aa,Ss,Dd,Ff,Gg,Hh,Jj,Kk,Ll,*+,§ù,Canc"))
'or
Ck.AddRowDoubleChar(Regex.Split("-","Aa-Ss-Dd-Ff-Gg-Hh-Jj-Kk-Ll-,.-*+-Canc"))
 
Last edited:

incendio

Well-Known Member
Licensed User
Longtime User
As already written it depends on the SD_CreativeBackground library, you can download it from here

I have already sd_creativebackground library, but on the example, it was not selected.
After selected, still got same error.
 

Star-Dust

Expert
Licensed User
Longtime User
I have already sd_creativebackground library, but on the example, it was not selected.
After selected, still got same error.
It should not be selected, it must be contained in the libraries.

The error you posted indicates it cannot find the library
 

Theera

Well-Known Member
Licensed User
Longtime User
If we use more 1 language,how to code? Is there example for me study?
 

incendio

Well-Known Member
Licensed User
Longtime User
I tried this code

Ck.AddRowSimpleChar(Regex.Split(",","100,1000,10000"))

When pressed 100 on virtual keyboard, the value displayed on EditText is 1.

Is it possible to display value on EditText same as virtual keyboard?

And how to display CAPSLOCK key?
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
If we use more 1 language,how to code? Is there example for me study?
You can use the Font property to determine a different Font or language font.
Obviously the TextFiled (or EditText) must have the same character

1645077982164.png
 

Attachments

  • aSample4.zip
    52.6 KB · Views: 330
  • jSample4.zip
    46.3 KB · Views: 304

Star-Dust

Expert
Licensed User
Longtime User
update rel 1.04
  • Added ClearKeyboard method to clear the keyboard with all the associations made with the views
  • Added AddRowStringtoKey method that allows you to associate a complex key with multi-character text. With this method it is not possible to set special keys such as Shift, Canc, Del, Tab, Esc, Next.
Sample:
Dim Ck As CustomKey
    Ck.Initialize
    Ck.AddRowSimpleChar(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P,Shift"))
    Ck.AddRowDoubleChar(Regex.Split(",","Aa,Ss,Dd,Ff,Gg,Hh,Jj,Kk,Ll,*+,§ù"))
    Ck.AddRowSimpleChar(Regex.Split(",","Z,X,C,V,B,N,M,Next" ))
    Ck.AddRowStringtoKey(Regex.Split(",","00,000,0000,Sorry,Hallo" ))
 
    SD_Keyboard1.Add(TextField1,"TextField1",Ck,null)
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Ck.AddRowStringtoKey(Regex.Split(",","00,000,000,1000" ))

Is there Ck.AddRowStringtoKey() in version 1.04?
 

Star-Dust

Expert
Licensed User
Longtime User
Yes
 

Theera

Well-Known Member
Licensed User
Longtime User
We can add imagetokey, can't we?, or we must use fontawesome only.
 
Top