Text Label formatting

Post your Gambas programming questions here.
Post Reply
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Text Label formatting

Post by Quincunxian »

Does anyone have an example of the syntax for text label formatting?
The gambas help gives this:
-------------------------------------------------------------------------------------------------------------
A rich text is a string using a subset of the HTML format.
The following HMTL markups are allowed:
<p> <br> <a> <font>
<b> <i> <s> <sub> <sup> <small> <tt> <u>
<h1> <h2> <h3> <h4> <h5> <h6>
The <font> markup understands the following attributes: face, color, and size.
-------------------------------------------------------------------------------------------------------------
What I want to do is change the text font colour.
I had assumed it would be something like this:
TextLable.Text = "Standard Colour <font 'color:red'> Color Red</font>"

or
TextLable.Text = "Standard Colour <font style='color:red'> Color Red</font>"

But it has no effect - so syntax is wrong.
Any examples appreciated.
Cheers - Quin.
I code therefore I am
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Text Label formatting

Post by BruceSteers »

Either...

Normal color <font color=red>and red</font>

Or use CSS style inside one of the supported tags..

Normal color
<p style="color:red">
red paragraph
</p>
If at first you don't succeed , try doing something differently.
BruceS
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Text Label formatting

Post by grayghost4 »

this works for me :

   Message(" <b> <font color='red'> Error number too large </font></b>", "Ok") 
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Text Label formatting

Post by BruceSteers »

Nope. I couldn't get style to work either.

But ...
TextLabel1.Text = "normal text <font color=red>red text</font>"



Works okay
If at first you don't succeed , try doing something differently.
BruceS
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Text Label formatting

Post by grayghost4 »

so I guess the Quotes are not needed :D

This will get you any color you want :

   Message(" <b> <font color=#00D000> Error number too large </font></b>", "Ok")


they must be disabled in reverse order, this will NOT work:
   Message(" <b> <font color=#00D000> Error number too large </b></font>", "Ok")
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Text Label formatting

Post by Quincunxian »

Thanks guys - Not sure what happened there, but the code from yesterday was not working and today it is :roll:
  
GameText = "Game: <font color=red> " & AV.GameName & "</font>"
GameText &= " - Player: <font color=yellow> " & AV.PlayerName & "</font>"
GameText &= " - Mode: <font color=cyan> " & AV.DiffAry[AV.GameMode] & "</font>"
Object.SetProperty(Ctrl, "Text", GameText)


I'm passing the TextLabel by reference and thought that this may have something to do with it but apparently not.
*sigh*
Cheers - Quin.
I code therefore I am
Post Reply