B4J Library [B4X] [XUI] SD_xComboBox

At the request of my friend @Mashiane , I created a combobox that has the graphics of my IconTextView that is Multiplatform (B4X, B4J, B4i)

NOTE: You can use this library for personal and commercial use. Include it in your projects.. Attention, even if it is a B4XLib library, it is not allowed to decompress it, modify it, change its name or redistribute it without the permission of the author


SD_xComboBox

Author:
Star-Dust
Version: 0.16
  • SD_xComboBox
    • Events:
      • ItemClick (Position As Int, Value As Object)
      • OpenList
    • Fields:
      • ItemHeight As Int
      • mBase As B4XView
      • OpenDropDownOnFocus As Boolean
      • Tag As Object
    • Functions:
      • Add (Text As String, ReturnValue As Object)
        Add Item
      • AddAll (L As List)
        Add List of Item, Return Value is a Text
      • Clear
      • CloseDropDown
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • GetBase As B4XView
      • GetItem (Position As Int) As String
      • GetValue (Position As Int) As Object
      • Initialize (Callback As Object, EventName As String)
      • isDropDownOpen As Boolean
      • OpenDropDown
      • SetSelection(Start As Int, Length As Int)
      • Size As Int
    • Properties:
      • Enabled As Boolean
      • Hint As String
      • HintFont As B4XFont
      • SelectedIndex As Int
      • SelectedTextItem As String
      • SelectOnlyFromList As Boolean
      • SelectedValueItem As Object
      • SelectionLenght As Int [read only]
      • SelectionStart As Int [read only]
      • TextFont As B4XFont

1.gif
2.gif
 

Attachments

  • SD_xComboBox.b4xlib
    4.9 KB · Views: 72
Last edited:

Dadaista

Active Member
Licensed User
Longtime User
Something like that. The border more fat :)... I am triying but the border is slim :(.... changing the border in properties

Thank you again @Star-Dust šŸ„°
 

Sergio Haurat

Active Member
Licensed User
Longtime User
@Star-Dust, I've spent days looking for this solution, thanks!

- I have found a problem, when the text can be edited, the cursor always moves to position 0, not to the end of the text. It would be convenient in any case, to select all the text to replace it with a new keyboard entry or to leave the cursor in the position that the user pressed.

ezgif-1-aa63e6a63e.gif


- An improvement would be to be able to search without distinguishing the upper case from the lower case
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.13
  • Added SetSelection(Start As Int, Length As Int)
  • Added SelectionStart and SelectionLength

With this it works every time the focus changes you can select the cursor wherever you want
B4X:
Private Sub xComboBox_FocusChanged (HasFocus As Boolean)
    xComboBox.SetSelection(xComboBox.SelectedTextItem.Length,0)
End Sub
 

Sergio Haurat

Active Member
Licensed User
Longtime User
This is where I see a problem. I don't understand if this is inside your code or if you propose to write it in my code.

My opinion:
'By not having the "if in focus" question, it always returns the cursor to zero position, even when exiting the combo.
Private Sub xComboBox_FocusChanged (HasFocus As Boolean)
  If HasFocus Then
   'How about selecting all? If I want to write again when typing the first character it replaces the entire text.
    xComboBox.SetSelection(0, xComboBox.SelectedTextItem.Length - 1)
  End If
End Sub

You can make the search not "equal to text", but instead the search to be "containing text" and not case sensitive
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
This is where I see a problem. I don't understand if this is inside your code or if you propose to write it in my code.

My opinion:
'By not having the "if in focus" question, it always returns the cursor to zero position, even when exiting the combo.
Private Sub xComboBox_FocusChanged (HasFocus As Boolean)
  If HasFocus Then
   'How about selecting all? If I want to write again when typing the first character it replaces the entire text.
    xComboBox.SetSelection(0, xComboBox.SelectedTextItem.Length - 1)
  End If
End Sub
write it in your code.
You can make the search not "equal to text", but instead the search to be "containing text" and not case sensitive
I will see for the next update
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.14
  • Added property: SelectOnlyFromList As Boolean

The text search does not only take place for the initial letters but for all the text in the field.
Ignore uppercase and lowercase and finally it is possible to select only from the list or type an element not present in the list with the SelectOnlyFromList command
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Kindly post an example that I can try
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.15
  • Fix bug
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.16
  • Fix bug
 
Top