settextareacolor - how to change some texts color

BlitzMax Forums/MaxGUI Module/settextareacolor - how to change some texts color

peltazoid(Posted 2007) [#1]
Hi, What I want to do is display some text that is outputted to a TextArea in a certain colour, say red for errors.

when I use SetTextAreaColor, this changes the colour of the text already in the TextArea and the new text as well.

How can you change the colour of the new text (i.e text to be added) without changing the whole TextArea?

Here is an example of the problem, I used a function for this test as that is how it is in my main project.

Blitz is up to date and I just synch'd the modules just in case.


win = CreateWindow("test",0,0,640,480)
box = CreateTextArea(0,0,640,480,win)

display(box, "hello")

Function display (output : TGadget , text$)
		
	AddTextAreaText(output , "some text") 

	' event loop so I can see what is happening.

	While WaitEvent()
		Select EventID()
		Case EVENT_WINDOWCLOSE
			Exit
		End Select
	 Wend

	
        'this changes "some text to green"
	SetTextAreaColor(output , 0 , 255 , 0)
	
	While WaitEvent()
		Select EventID()
		Case EVENT_WINDOWCLOSE
			Exit
		End Select
	 Wend
	
        ' adds more green text.
	AddTextAreaText(output , text$) 

End Function


While WaitEvent()
	
	Select EventID()
	Case EVENT_WINDOWCLOSE
		End
	End Select
	
Wend


Thanks


grable(Posted 2007) [#2]
I think what you want is FormatTextAreaText()


assari(Posted 2007) [#3]
There's an example on how to FormatTextAreaText use function here
http://www.2dgamecreators.com/maxgui/T16%20-%20Textarea.html#mozTocId597924


peltazoid(Posted 2007) [#4]
That looks like what I'm after.

I expected SetTextAreaColor to work like the SetColor in graphics mode, when you change the colour it affects all future drawing/text commands.

Cheers.


peltazoid(Posted 2007) [#5]
Then again, maybe it is not. I can work around it, i.e. store the cursor position, output the text, then format from the stored postion to the length of the text.

But what I really need is to be able to set the colour of the text to be written, that would be a lot nicer.