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
 

Attachments

  • jSD_CustomKeyboard 1.20.zip
    25.1 KB · Views: 98
  • iSD_CustomKeyboard 1.20.zip
    324.2 KB · Views: 93
  • SD_CustomKeyboard 1.20.zip
    28.7 KB · Views: 132
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
for now you can select any font you like, even awesome.
 

Star-Dust

Expert
Licensed User
Longtime User
Keyboard located at the top right
Add sample here

1645088174801.png
 
Last edited:

Gabino A. de la Gala

Active Member
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,000,1000,Hallo" ))
 
    SD_Keyboard1.Add(TextField1,"TextField1",Ck,null)
¿What about to can addRowStringToKey like +1, +10. +100, +1000 and to put the result of the successive additions to the textfield?
 

Star-Dust

Expert
Licensed User
Longtime User
¿What about to can addRowStringToKey like +1, +10. +100, +1000 and to put the result of the successive additions to the textfield?
No, lo que me pediste es tener Claves que ingresen varios caracteres en lugar de uno solo. Me imagino una caja registradora similar que puede llegar a 00 o 000 seguidos para completar un recibo
_____________________________________
No, what you asked me is to have Keys that enter multiple characters instead of just one. I imagine similar cash register that can hit 00 or 000 in a row to fill out a receipt
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
No, lo que me pediste es tener Claves que ingresen varios caracteres en lugar de uno solo. Me imagino una caja registradora similar que puede llegar a 00 o 000 seguidos para completar un recibo
_____________________________________
No, what you asked me is to have Keys that enter multiple characters instead of just one. I imagine similar cash register that can hit 00 or 000 in a row to fill out a receipt
Yes, it is something similar to that. But instead of adding zeros at the end, what it does is a calculation so that if you click on the buttons: +1000+100+1+1, the result is: 1102.
 

Star-Dust

Expert
Licensed User
Longtime User
The idea sounds nice but it would turn a keyboard into a calculator. You don't need to implement it on the keyboard, just implement it inside the TextChange event
 

Star-Dust

Expert
Licensed User
Longtime User
update rel 1.05
  • Added Vibration option in design
 

Star-Dust

Expert
Licensed User
Longtime User
Update 1.06
  • Add new Key: EraseAll. Delete all text in the field
  • Added: LightFactor and DarkFactor property
NB. Use SD_CreativeBackground 1.05+ (update the library if necessary)
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
The iOS version has also been released. You can download it from the post #1
 

Lello1964

Well-Known Member
Licensed User
Longtime User
I am using the keyboard for Android and it is very comfortable especially because I can size it, customize it and place it wherever I want. It is a library that many will surely use after trying it. Thanks SD.
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.07
  • Now the special keys are created with the MaterialIcons font. Remember to load the font by selecting this command:
    B4X:
    SD_Keyboard1.SpecialKeyFont = xui.CreateMaterialIcons(16)
  • 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

There will be other news in the coming days .....
 

Zoran Vujacic

Member
Licensed User
Is there a way to use this keyboard as the default on Android (input methods, such as gboard ...)? For my huge fingers, such a possibility would be phenomenal :)
Thanks anyway!
I noticed that the graphic animation of pressing the button reacts only when the button is released (Android).
 

Star-Dust

Expert
Licensed User
Longtime User
I don't know if there is a method to make it default on Android. But I'm still developing it, if I find a way I'll post an example.
 

joko0124

Member
Licensed User
Longtime User
HI! I've tried your library and within your samples, I am getting this error when I am tapping any keys from your Custom Keyboard:

1645433415605.png


sd_keyboard$ResumableSub_Key_Pressresume (java line: 758)
 

Star-Dust

Expert
Licensed User
Longtime User
I am working on the possibility of adding custom keys such as those of the cash registers.
For example, those to select the DEPARTMENT (REP.1, REP.2) and consequently the related VAT category
1645545717173.png




Custom background
1645479892054.png
 
Last edited:

joko0124

Member
Licensed User
Longtime User
Please post logs as text not images. You can right click on the log pane to copy the text.
** Activity (main) Resume **
Focus1: true
sd_keyboard$ResumableSub_Key_Pressresume (java line: 758)
java.lang.NoSuchMethodError: No virtual method getSelectionStart()I in class Lanywheresoftware/b4a/objects/B4XViewWrapper; or its super classes (declaration of 'anywheresoftware.b4a.objects.B4XViewWrapper' appears in /data/app/b4a.example-2/base.apk)
at b4a.example.sd_keyboard$ResumableSub_Key_Press.resume(sd_keyboard.java:758)
at b4a.example.sd_keyboard._key_press(sd_keyboard.java:722)
at b4a.example.sd_keyboard._keypress_click(sd_keyboard.java:1454)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22298)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
sd_keyboard$ResumableSub_Key_Pressresume (java line: 758)
java.lang.NoSuchMethodError: No virtual method getSelectionStart()I in class Lanywheresoftware/b4a/objects/B4XViewWrapper; or its super classes (declaration of 'anywheresoftware.b4a.objects.B4XViewWrapper' appears in /data/app/b4a.example-2/base.apk)
at b4a.example.sd_keyboard$ResumableSub_Key_Press.resume(sd_keyboard.java:758)
at b4a.example.sd_keyboard._key_press(sd_keyboard.java:722)
at b4a.example.sd_keyboard._keypress_click(sd_keyboard.java:1454)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22298)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
 

Star-Dust

Expert
Licensed User
Longtime User
** Activity (main) Resume **
Focus1: true
sd_keyboard$ResumableSub_Key_Pressresume (java line: 758)
java.lang.NoSuchMethodError: No virtual method getSelectionStart()I in class Lanywheresoftware/b4a/objects/B4XViewWrapper; or its super classes (declaration of 'anywheresoftware.b4a.objects.B4XViewWrapper' appears in /data/app/b4a.example-2/base.apk)
at b4a.example.sd_keyboard$ResumableSub_Key_Press.resume(sd_keyboard.java:758)
at b4a.example.sd_keyboard._key_press(sd_keyboard.java:722)
at b4a.example.sd_keyboard._keypress_click(sd_keyboard.java:1454)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22298)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
sd_keyboard$ResumableSub_Key_Pressresume (java line: 758)
java.lang.NoSuchMethodError: No virtual method getSelectionStart()I in class Lanywheresoftware/b4a/objects/B4XViewWrapper; or its super classes (declaration of 'anywheresoftware.b4a.objects.B4XViewWrapper' appears in /data/app/b4a.example-2/base.apk)
at b4a.example.sd_keyboard$ResumableSub_Key_Press.resume(sd_keyboard.java:758)
at b4a.example.sd_keyboard._key_press(sd_keyboard.java:722)
at b4a.example.sd_keyboard._keypress_click(sd_keyboard.java:1454)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22298)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
It is not clear what that could be. Because it is looking for the start of the cursor in a View which is not an EditText or TextField but a panel.

Are you sure you haven't changed the original source?
Are you using the latest version of B4a?
 
Last edited:

joko0124

Member
Licensed User
Longtime User
It is not clear what that could be. Because it is looking for the start of the cursor in a View which is not an EditText or TextField but a panel.

Are you sure you haven't changed the original source?
Are you using the latest version of B4a?
Yes, I'm sure that I am using the original source however I am not using the latest B4A version for I am having a problem with my original program when upgrading to version 11. And honestly, I am looking for this library for so long. Maybe you can help me? I am still using V10.0
 
Top