TextArea Colour Question.

Post

Posted
Rating:
#1 (In Topic #1594)
Regular
JMathers is in the usergroup ‘Regular’
 Hi, thanks for reading

so my question is pretty simple,

is there a way to colour the text in a textArea box

i'm making a search feature (what works perfect)

but i want to maybe change the size of "Result(s) ; " & "\n"
maybe make it bold / underlined, maybe change the colour to red or something.
i can't seem to find any documentation for it.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 if you are looking to change the entire box then you need to access the correct property..    text.font.color = gb.red    would do it.  but that changes the entire box.  if you want only a part then you would need a different control. In fact I doubt you could use a textbox I think you'd need a textlabel then you can use basic HTML coding to change color for a portion of the box. such as

textlabel.text="This is normal text. <b> this is bold </b> and this <font color=" & chr(34) & "FF0000" & chr(34) & "> is my red. </font>"

not sure if the chr(34) which is a quote is needed or not. but that would be HTML coding for what you see.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
JMathers is in the usergroup ‘Regular’
 yeah, i wanted to avoid using html coding

but gambas 3 says TextArea (gb.gui)
thats what i use. but yeah,
i tried html code with textlabels and such with no results, i think i'd need to throw it though a html viewer.
but i'll try again.

but your textabel.text=..
is how i want to do it, just change parts of the results and colour, not the entire thing.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’

JMathers said

yeah, i wanted to avoid using html coding

but gambas 3 says TextArea (gb.gui)
thats what i use. but yeah,
i tried html code with textlabels and such with no results, i think i'd need to throw it though a html viewer.
but i'll try again.

but your textabel.text=..
is how i want to do it, just change parts of the results and colour, not the entire thing.

html code (or RichText to be more accurate) With a RichText compliant Control like TextLabel is the only simple way really.
unless you want to use markdown then gb.markdown can convert that to html with a HtmlView

RichText is quite limited compaired to full html though.

Don't let the word Text in TextLabel and TextArea confuse you, they are different things.
TextArea is just a multi line TextBox, it basically has what a TextBox has in features.

TextLabel is a Label that supports RichText. (plus some nice Border options)

sadams54 was correct but missed the # hash for RGB hexidecimal like #FF0000
(quotes are not needed)
you can also use basic html color names like red yellow magenta etc

Example…

Code (gambas)

  1.  
  2. TextLabel1.Text = "Hi <font color=red>this is red text</font> and also "
  3.                   "<font size=+2><b>big and bold</b></font> or "
  4.                   "<font color=#00FF00>green text using #RRGGBB</font>"
  5.  
  6.  

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
JMathers is in the usergroup ‘Regular’
hi Bruce.

i tried that 1, but i couldn't work out how to make it go multi-lined.
so i abandoned it for the time in search for a multi lined option.
i tried \n , and chr(13) & chr(10) and looked for a .multi or something.

Code (gambas)

  1.  
  2. TextArea1.Text = "<b>Search Result</b> ; " & "\n" & "\n" & resultText
  3.  TextLabel1.Text = "<b>Search Results</b> ; " & Chr(10) & Chr(13) & "(" & count & ")" & "\n" & "\n" & resultText
  4.  
in the textarea1 it works perfectly
but the textlabel it doesn't so..yeah  :?:
JM
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

JMathers said

hi Bruce.

i tried that 1, but i couldn't work out how to make it go multi-lined.
so i abandoned it for the time in search for a multi lined option.
i tried \n , and chr(13) & chr(10) and looked for a .multi or something.

Code (gambas)

  1.  
  2. TextArea1.Text = "<b>Search Result</b> ; " & "\n" & "\n" & resultText
  3.  TextLabel1.Text = "<b>Search Results</b> ; " & Chr(10) & Chr(13) & "(" & count & ")" & "\n" & "\n" & resultText
  4.  
in the textarea1 it works perfectly
but the textlabel it doesn't so..yeah  :?:
JM
Try:

Code

<br>

Think RichText, not Plain Text

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’
yes RichText is like cut down HTML you can only use <HTML> tags for text formatting.
line break with either the "line break" tag <br>
or the paragraph tag <p>

Code (gambas)

  1. TextArea1.Text = "<b>Search Result</b> ;<br><br>" & resultText
  2.  

Code (gambas)

  1. TextArea1.Text = "<b>Search Result</b> ;<p>" & resultText
  2.  
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
JMathers is in the usergroup ‘Regular’

BruceSteers said

yes RichText is like cut down HTML you can only use <HTML> tags for text formatting.
line break with either the "line break" tag <br>
or the paragraph tag <p>

Code (gambas)

  1. TextArea1.Text = "<b>Search Result</b> ;<br><br>" & resultText
  2.  

Code (gambas)

  1. TextArea1.Text = "<b>Search Result</b> ;<p>" & resultText
  2.  

S.O.B.. @£$*£(***..

Thank you BruceSteers <3 <3 <3 <3 <3 <3


@devs
how about adding a bit on build in information. on all these different styles when formatting these.  :!:
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

JMathers said

how about adding a bit on build in information. on all these different styles when formatting these.  :!:
How about you doing some more effort in searching for things?
I typed 'gambas wiki rich text ' in a search engine and got what the devs wrote on gambas wiki: https://gambaswiki.org/wiki/doc/richtext

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’

gbWilly said

JMathers said

how about adding a bit on build in information. on all these different styles when formatting these.  :!:
How about you doing some more effort in searching for things?
I typed 'gambas wiki rich text ' in a search engine and got what the devs wrote on gambas wiki: https://gambaswiki.org/wiki/doc/richtext

 :lol: haha :)

He's Right though JMathers, the wiki page for the TextLabel has a link to the RichText info page https://gambaswiki.org/wiki/doc/richtext

It's technically no longer gambas help
It's a little HTML understanding.

I just added some more info to the gambas wiki but if not logged in it will not show till tomorrow.

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#11
Regular
JMathers is in the usergroup ‘Regular’
interesting. every time i do a search i don't get results like that

thanks for the URL, i book marked it. :!:
Online now: No Back to the top

Post

Posted
Rating:
#12
Guru
BruceSteers is in the usergroup ‘Guru’

JMathers said

interesting. every time i do a search i don't get results like that

thanks for the URL, i book marked it. :!:

Perhaps if you used the gambas wiki more it will begin to show as a higher priority in your search result algorithms ?

The wiki is the go-to place for information.
It is also the source of the gambas IDE inline help popups.

/ - Gambas Documentation

We can be a bit "RTFM!" here as many of us have contributed to the wiki (like me adding that info yesterday)
If you're going to learn gambas that's the start point, the built-in reference manual.

It takes a little time to get used to it's layout but the main places to recommend are…
Language Index, Language overviews
Native classes , GUI classes
Then Components

Another way to open the wiki in the IDE is to press F1 or click the "? / Help browser" menu item
Online now: No Back to the top

Post

Posted
Rating:
#13
Regular
JMathers is in the usergroup ‘Regular’
 I’m going to let you go, but this has been really helpful, Thanks for your insight.
Online now: No Back to the top
1 guest and 0 members have just viewed this.