B4A Library [B4X] SD CustomKeyboard

For B4A, B4J, B4i

IMPORTANT
  • depends on SD CreativeBackGround (0.05+) 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.15
  • 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
      • 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
      • 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

Important depends on SD CreativeBackGround library which must be downloaded
 

Attachments

  • iSD_CustomKeyboard 1.15.zip
    310.9 KB · Views: 60
  • SD_CustomKeyboard 1.15.zip
    28.9 KB · Views: 70
  • jSD_CustomKeyboard 1.15.zip
    24.7 KB · Views: 62
Last edited:

agraham

Expert
Licensed User
Longtime User
I am having a problem with my original program when upgrading to version 11.
You need to upgrade to B4A v 11.2, install a fresh SDK and then solve the problem with your code. Post the problem on the forum to get help with it. There is no point in using an old and unsupported version of B4A. Those of us who advise on the forum are all running the latest version.
 

joko0124

Member
Licensed User
You need to upgrade to B4A v 11.2, install a fresh SDK and then solve the problem with your code. Post the problem on the forum to get help with it. There is no point in using an old and unsupported version of B4A. Those of us who advise on the forum are all running the latest version.
Thank you so much for your advice. Indeed, I am stuck with the old version and yes, I'll try to recode my program using the latest version.
 

Star-Dust

Expert
Licensed User
Update 1.08
  • Add a character to the last row entered on the keyboard and customized keys with the possibility of establishing their size
  • Ability to customize the background with an image
  • Possibility to insert empty spaces between the keysAdd a character to the last line entered on the keyboard
  • Possibility to set the StartSelect always at the end (Fields InsertAlwaysAtEnd)

Add a character to the last row:
Ck.AddKeytoLastRow("A",65,"a",97,2)  ' 2-seater wide button
Customize background:
SD_Keyboard1.ImageBackground=xui.LoadBitmap(File.DirAssets,"1.png")
empty spaces:
Ck.AddKeytoLastRow("",0,"",0,1)
Always inserts typed characters at the end:
SD_Keyboard1.InsertAlwaysAtEnd=True
 
Last edited:

Star-Dust

Expert
Licensed User
Example n.6

1645734569651.png
 

Attachments

  • aSample6.zip
    101.8 KB · Views: 36
  • iSample6.zip
    154.3 KB · Views: 31
  • jSample6.zip
    95.4 KB · Views: 35

Star-Dust

Expert
Licensed User
update 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 do not raise the TextChange event but the new CustomKey event
    Example: Sub TextField1_CustomKey (Code As Int)
  • Added new event to TextField or EditText view to handle custom keys that must have a negative return code and will raise the CustomKey event.

Example of custom keys

B4X:
Sub Mycode
    SD_Keyboard1.SpecialKeyFont=xui.CreateMaterialIcons(16)

    Dim Ck As CustomKey
    Ck.Initialize
    Ck.AddRowSimpleChar(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P,Shift"))
    ck.AddKeytoLastRow("REP.3",-133,"rep.3",-133,2) ' For Customize key - Negative value codes only  from -11 to -255
    SD_Keyboard1.Add(TextField1,"TextField1",Ck,null)
End SUb

Private Sub TextField1_CustomKey(Code As Int)
    Log(Code)
    if code=-133 then
        ' my code'
    End if
End Sub
 
Last edited:

Blueforcer

Well-Known Member
Licensed User
Longtime User
Is it possible to change the colors from code?
I switch colorschemes during runtime and it would be great if i can apply it to the keyboard as well.
Thanks
 

Star-Dust

Expert
Licensed User
At the moment it is not possible, I will try to insert it in the next versions
 

Star-Dust

Expert
Licensed User
Update 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
1646370102911.png
 
Last edited:

Star-Dust

Expert
Licensed User
Update 1.13
  • Set Shift key by code
  • Fix bugs
 

Star-Dust

Expert
Licensed User
Update 1.14
  • Added AddEmpyKeyToLastRow method in CustomKey class
  • Added cEmptyKey method in CustomKey class
Allows you to insert blank spaces on the keyboard
B4X:
Dim ck As CustomKey
ck.Initialize
ck.AddRowSimpleChar(Regex.Split(",","7,8,9"))
ck.AddEmptySpaceToLastRow 
ck.AddCustomKeyToLastRow("F1",-15,"f1",-16,1,0xFF6495ED,0xffffffff)

' or
ck.Initialize
ck.AddRowSimpleChar(Regex.Split(",","7,,8,9")) ' Added space in the center

'or
Ck.Initialize
Ck.AddRowSimpleChar(Array As String("A","","C","D")) ' Added space in the center
ck.AddEmptySpaceToLastRow 'Added another space in the left

1647066319776.png
 
Last edited:

Star-Dust

Expert
Licensed User
How to add a Custom Key to the left side of a line
B4X:
Dim L As List
L.Initialize
L.Add(Ck.cKeyCustomized("REP.3",-133,"rep.3",-133,2,0xFFFF6159,xui.Color_White)) 'Custom Key
Ck.AddRow(L)
Ck.AddSimpleCharToLastRow(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P,Shift"))

How to add a custom key to the right side of a line
B4X:
Ck.AddSimpleChar(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P,Shift"))
Ck.AddCustomKeyToLastRow("REP.3",-133,"rep.3",-133,2,0xFFFF6159,xui.Color_White) 'Custom Key

How to add a Custom key in the middle of a line
B4X:
Ck.AddSimpleChar(Regex.Split(",","Q,W,E,R,T,Y"))
Ck.AddCustomKeyToLastRow("REP.3",-133,"rep.3",-133,2,0xFFFF6159,xui.Color_White) 'Custom Key
Ck.AddSimpleCharToLastRow(Regex.Split(",","U,I,O,P,Shift"))
 
Last edited:

Cesaral

Member
Congratulations and thanks for such a great library!

In the spanish keyboard (it happens the same in many languajes) there are for example vowels (a, e, i, o, u) that can have or not an accent. In the Android original keyboard, if you hold the tab action on a vowel, then an extra floating window appears where you can then select the vowel with different accents...

Can this be done with this library?
 

Star-Dust

Expert
Licensed User
Congratulations and thanks for such a great library!

In the spanish keyboard (it happens the same in many languajes) there are for example vowels (a, e, i, o, u) that can have or not an accent. In the Android original keyboard, if you hold the tab action on a vowel, then an extra floating window appears where you can then select the vowel with different accents...

Can this be done with this library?
At the moment I have not thought of this option. But I will take this into account in future updates
 

Star-Dust

Expert
Licensed User
Update 1.15
  • Added AddEmptyRow method in CustomKey class
How to add a Custom Key to the left side of a line (with AddEmptyRow)
B4X:
Dim L As List
L.Initialize
Ck.AddEmptyRow
Ck.AddCustomKeyToLastRow("REP.3",-133,"rep.3",-133,2,0xFFFF6159,xui.Color_White) 'Custom Key
Ck.AddSimpleCharToLastRow(Regex.Split(",","Q,W,E,R,T,Y,U,I,O,P,Shift"))
 

astronald

Member
Licensed User
Longtime User
Hello great project, but i cant works properly on B4xPages,
can you upload sample, please thanks.
 

Star-Dust

Expert
Licensed User
Salutations,

What problems do you have with B4XPage?
 

Theera

Well-Known Member
Licensed User
Longtime User
In future,Is there fractions keyboard?
 
Top