B4J Question [Solved] B4XFloatTextField. Is it possible access to multiline property in run time?

TILogistic

Expert
Licensed User
Longtime User
Yes and No

Yes.

The multiline property is checked in the designer.

Because?

The view creates two types of field based on this property (multiline).

If checked, create a TextArea, otherwise a TextField

B4J:


 
Last edited:
Upvote 0

Dadaista

Active Member
Licensed User
Longtime User
Thx @oparra. I did not know that.

I am in trouble with a B4XFloatTextField

I am using the code provided by @oparra to set border, color and hint text adjust to the right. The code works like a charm

B4X:
Public Sub SetFloatTextField(FloatTextField As B4XFloatTextField)
    Dim TextFont As B4XFont = xui.CreateFont2(FloatTextField.HintFont, FloatTextField.SmallLabelTextSize)
    Dim TextWidth As Int = MeasureTextWidth(FloatTextField.HintText, TextFont)
    Dim BorderRadius As Int = FloatTextField.TextField.Height / 2
    
    FloatTextField.HintLabelSmallOffsetY = 5
    FloatTextField.HintLabelSmallOffsetX = FloatTextField.TextField.Width - (TextWidth + BorderRadius)
    FloatTextField.Update
    FloatTextField.TextField.SetColorAndBorder(xui.Color_Black, DipToCurrent(3), xui.Color_White, BorderRadius)
End Sub

Private Sub MeasureTextWidth(t As String, f As B4XFont) As Float
    Dim MeasuringCanvas As B4XCanvas
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 2dip, 2dip)
    MeasuringCanvas.Initialize(p)
    Return MeasuringCanvas.MeasureText(t, f).Width
End Sub

Now there is a multiline field and it background appears in white color. The color must be black. I thought setting multiline in run time would solve the problem (it is silly ?)

Must be like this


It appears like this


Well, I will look for this in the forum to solve it

Thank you very much @oparra !!
 
Upvote 0

Dadaista

Active Member
Licensed User
Longtime User
Hi
Thx for your time @oparra
I turn back to TextArea control ussing CSS like it was before the change to B4XFloatTextField
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
The change to do this is very simple.

Tell me if you are using B4XPages or not.

You just have to add one line of code.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Attached test file. You just need to add the css file, which models only the textarea type fields.

You can use it on B4J, B4Xpages or Normal.

Just add this line of code:
MainForm = Form1
MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Style.css"))
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show





Regards.
 

Attachments

  • B4J-B4XFloatTextField.zip
    3.4 KB · Views: 281
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…