B4J Question Text and Back grounds in Textfields

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All

Just starting in B4J and keep hitting the wall at Textfields

Textfield background: In Visual Designer, Background Properties/Color Drawable. No matter what color is selected the background is white.

Text Properties: In Visual Designer Font/Size. No matter what size is set the compiled resultant size does not change.

Text Colors: Not available in Visual Designer.
In AppStart I have tried "Textfield1.Style = "-fx-font-color: gold;"". Font color remains black.

All of the above are easy in VD for Labels, I am missing something for Textfields.

Regard Roger
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Zip file attached. It's the Google maps example with bits tacked on as learning exercise.
I have, since posting, found that the Visual Designer [VD] settings "sort of" work until I try to use style to set the text color to White. It looks like the use of Style overwrites what is set in the VD.
I have set the background of the Textfield to transparent but when focused the TF turns blue. Is there any way to stop this?
The TF appears to have significant padding, requiring a larger TF to accomodate the size font required. Any simple method to manage padding?

Sorry about the extra questions but they are all about configuring the TF and it's text.

Regards Roger
 

Attachments

  • ABT.zip
    17.8 KB · Views: 213
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
That's correct. Instead of setting the style you need to append any addition string you like to the existing style.


What is not working?
From first post.

Textfield background: In Visual Designer, Background Properties/Color Drawable. No matter what color is selected the background is white.

Text Properties: In Visual Designer Font/Size. No matter what size is set the compiled resultant size does not change.

Roger
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is how it looks when I run it:

SS-2015-11-19_09.39.20.png


What is "sort of" working? As I wrote above you shouldn't overwrite the style. You should instead append more attributes if you like.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel

What you show is also what I am getting. However I need to change the text color to White. As I understand it, the way to do this is with a Style attribute. I have attempted to do this, see the commented out code in "Sub AppStart".

It isn't that I have overwritten Style, but rather when I use Style in the code, it appears to overwrite the Background and Font Size settings of the VD with default values.

Can you please try using code to change the Text Color. IE: DispTitle.Style = "-fx-text-fill: white;" I think you will see the problem.

As I see it at the moment, not all required parameters can be set in the VD so the use of Style is required to set some parameters. IE Text Color
If Style is used, the settings in the VD are lost.
This means all parameters must be set in Styles attributes or defaults are used. EG Height, TextSize, TextColor, etc.
If this is correct, is there a newbies guide to Style attributes?

Regards
Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Thanks Erel,

The code [DispTitle.Style = DispTitle.Style & "-fx-text-fill: white;" ] works in AppStart but obviously as Extra CSS is in Background Properties it's no use for Text Color.

The most outsatnding question is still: Is there a reference for Style attributes? IE "-fx-height: 25;" etc. Where do we find the attributes?


Thanks for your help

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel,

Thanks for the CSS link. Reading that will keep me busy.

I have tried removing [DispTitle.Style = DispTitle.Style & "-fx-text-fill: white;"] from AppStart and pasted it into CSS in the VD. The result is Black Text, not White.


Regards Roger

PS I will start a new thread for other questions.

Additional Info:
If I put -fx-text-fill: white; into the CCS field I get White text.:)
If I put -fx-padding: 0; the padding is zero.:)
I can't work out the correct syntax to use both.:(

Roger
 
Last edited:
Upvote 0
Top