iOS Question B4XComboBox TextColor in Cross Platform App

aminoacid

Active Member
Licensed User
Longtime User
Is there ANY way to change the awful blue text color in a B4XComboBox running in a B4I application on an iOS device.

I have created a Cross Platform Application using B4XPages and XUI and I can easily change the text color and background color of the ComboBox in the B4A and B4J apps but not in B4I.

I did read a post where it said that it was not possible. But that was an old post so I'm just checking to see if this limitation has been overcome in some way.

Thanks!
 

jahswant

Well-Known Member
Licensed User
Longtime User
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
In B4i the text field is actually a button.
There is an internal item called mBtn.

So you can use:
B4X:
   Private cmb As B4XComboBox
    cmb.mBtn.As(B4XView).TextColor = col
    cmb.mBtn.SetColorAndBorder(bcol,1dip,bbcol,0dip)

You should wrap it in #if b4i though
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
I’m sure that he is asking more for list elements. Those elements can’t get a different color.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
In B4i the text field is actually a button.
There is an internal item called mBtn.

So you can use:
B4X:
   Private cmb As B4XComboBox
    cmb.mBtn.As(B4XView).TextColor = col
    cmb.mBtn.SetColorAndBorder(bcol,1dip,bbcol,0dip)

You should wrap it in #if b4i though

Thanks for the tip. It's exactly what I need to do.... simply change the text color to white with a black background. However it still does not work. Here is what I did:

B4X:
    Private B4XComboBox1 As B4XComboBox

    #if B4I
        B4XComboBox1.mBtn.As(B4XView).TextColor=XUI.Color_White
        B4XComboBox1.mBtn.SetColorAndBorder(XUI.Color_Black,1dip,XUI.Color_Black,0dip)
    #End If

The background color does change to Black as intended (the background color can also be changed in designer). However the text color remains set to Blue.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I’m sure that he is asking more for list elements. Those elements can’t get a different color.

Actually, No. All I need to do is change the color of the text in the combo box. The background color does change if I set it in designer. But the text color does not.
The ComboBox you suggested looks great, but at this point I'd rather stick with the same B4XCombobox if its possible to something as simple as changing the text color.

Thanks!
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Try this instead.

B4X:
 Private B4XComboBox1 As B4XComboBox

    #if B4I
        SetAllButtonTextColor(b4xComboBox1.mBtn,xui.Color_white)
        B4XComboBox1.mBtn.SetColorAndBorder(XUI.Color_Black,1dip,XUI.Color_Black,0dip)
    #End If


Sub SetAllButtonTextColor(btn As Button, clr As Int)
state: 0 = normal, 1 = pressed, 2 = disabled
    Dim no As NativeObject = btn
    no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), 0))
    no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), 1))
    no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), 2))
End Sub
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Try this instead.

B4X:
 Private B4XComboBox1 As B4XComboBox

    #if B4I
        SetAllButtonTextColor(b4xComboBox1.mBtn,xui.Color_white)
        B4XComboBox1.mBtn.SetColorAndBorder(XUI.Color_Black,1dip,XUI.Color_Black,0dip)
    #End If


Sub SetAllButtonTextColor(btn As Button, clr As Int)
    'state: 0 = normal, 1 = pressed, 2 = disabled
    Dim no As NativeObject = btn
    no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), 0))
    no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), 1))
    no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), 2))
End Sub

That did it! Thank you.
And I see what you are doing .... pretty nifty, I must say! :)
 
Upvote 0
Top