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: 111
  • iSD_CustomKeyboard 1.20.zip
    324.2 KB · Views: 108
  • SD_CustomKeyboard 1.20.zip
    28.7 KB · Views: 149
Last edited:

astronald

Active Member
Licensed User
Longtime User
Hi Star-Dust, I don't know if it's something wrong in the library but in B4i 8.30 it doesn't work(Local Builder), i got this errror

B4X:
Objects-normal/arm64/b4i_main.o
In file included from /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/b4i_main.h:3:9: fatal error: 'iSD_CustomKeyboard.h' file not found
#import "iSD_CustomKeyboard.h"
        ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.

CompileC /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.o /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/LS_page1.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'B4iProject' from project 'B4iProject')
    cd /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target arm64-apple-ios8.0 -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/var/folders/z0/gw19pzhx0fbfzc5mblpjklth0000gn/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -Wno-implicit-fallthrough -DB4I_VERSION\=14 -DNS_BLOCK_ASSERTIONS\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility\=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -iquote /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/Payload/include -I/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources-normal/arm64 -I/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.d --serialize-diagnostics /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.dia -c /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/LS_page1.m -o /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.o

CompileAssetCatalog /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/Payload/B4i\ Example.app /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/Images.xcassets (in target 'B4iProject' from project 'B4iProject')
    cd /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>
    /Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/assetcatalog_dependencies --output-partial-info-plist /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/assetcatalog_generated_info.plist --app-icon AppIcon --enable-on-demand-resources YES --development-region English --target-device iphone --target-device ipad --minimum-deployment-target 8.0 --platform iphoneos --compile /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/Payload/B4i\ Example.app /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/Images.xcassets


Error: ** BUILD FAILED **


The following build commands failed:
    CompileC /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o /Users/rocas/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'B4iProject' from project 'B4iProject')
(1 failure)
 

Attachments

  • test.zip
    3 KB · Views: 93

Star-Dust

Expert
Licensed User
Longtime User
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I'm studying the possibility of customizing the shape of the buttons.
Not sure if this feature will be included in future updates

1685437800123.png


1685437931720.png
 

Star-Dust

Expert
Licensed User
Longtime User
Update. rel1.19
  • Added KeyStyle property (0-Standard; 1-Comics; 2-Heart; 3-Flower; 4-Octagon)
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update. rel 1.20
  • fix bug
 

madru

Active Member
Licensed User
Longtime User
happy new year :)

Is it possible to hide the "original keyboard" completely?
When I move between the text boxes by clicking on them, I can see the "original keyboard" opening and closing for a short time...
 

Star-Dust

Expert
Licensed User
Longtime User
happy new year :)

Is it possible to hide the "original keyboard" completely?
When I move between the text boxes by clicking on them, I can see the "original keyboard" opening and closing for a short time...
Hi,
Unfortunately this depends on the device, in the majority it does not have time to appear, but in some rare devices it happens more slowly and is therefore visible.
 

adriano.freitas

Active Member
Great work!

I have a question about something I need and I don't know if I can solve it with this library. In addition to building a custom keyboard, I need a key to show one thing but send another to a text box. Is there a way to do it? I need this because I have a text box whose content could have a special control character. Normally it doesn't work, but being able to customize the idea is that the keyboard shows it as the character but when sending it to the box I can use an alternative character to represent the character that the system cannot normally handle. Can anyone help me with something that allows me to do this using this keyboard or even some possibility of intercepting keys on the common keyboard and changing them?
 

Star-Dust

Expert
Licensed User
Longtime User
Great work!

I have a question about something I need and I don't know if I can solve it with this library. In addition to building a custom keyboard, I need a key to show one thing but send another to a text box. Is there a way to do it? I need this because I have a text box whose content could have a special control character. Normally it doesn't work, but being able to customize the idea is that the keyboard shows it as the character but when sending it to the box I can use an alternative character to represent the character that the system cannot normally handle. Can anyone help me with something that allows me to do this using this keyboard or even some possibility of intercepting keys on the common keyboard and changing them?
Yes you can do this using customizable keys. A text appears and inserts a chosen characterYes you can do it using Custom keys
AddCustomKeyToLastRow
 

Star-Dust

Expert
Licensed User
Longtime User
I am working on a new version of the library which may not be perfectly compatible with the previous one but will add the possibility of inserting for each character, in addition to uppercase and lowercase, also alternative keys for accented ones or for any use.
Long clicking on a key (or with the right mouse button on the PC) will open a further menu relating to that key with the variations.

I'm still working on the graphics and some other technical details, but there will be a new version soon. Those who want to use the old methods can continue to use the old library.

B4X:
ck.AddKeyToLastRow2("E",69,"e",101,CreateMap("È":200,"É":201,"Ê":202,"Ë":203),CreateMap("è":232,"é":233,"ê":234,"ë":235),1)

1711458436019.png
 

Star-Dust

Expert
Licensed User
Longtime User
THIS VERSION WILL NO LONGER BE UPDATED OR RECEIVE SUPPORT.

If you want you can use the new version (HERE)
 
Top