FormatTextAreaText

BlitzPlus Forums/BlitzPlus Programming/FormatTextAreaText

WolRon(Posted 2004) [#1]
How in the hell do you set TextArea text back to normal?

I can successfully use FormatTextAreaText to set the text color to anything I want.

But if I use FormatTextAreaText to set the text to bold, itelic, or bold/italic, there doesn't appear to be any way to set it back to normal. I can only set it to one of those three formats.

Passing FormatTextAreaText a parameter of 0 (zero) for the format flag doesn't appear to do a thing.

There MUST be a way to set it back to normal???


soja(Posted 2004) [#2]
You must be doing it wrong =)
to whit:
w=CreateWindow("", 100,100,200,200)
t=CreateTextArea(0,0,ClientWidth(w), ClientHeight(w),w)
SetTextAreaText(t,"click me click me click me")
Repeat
Select WaitEvent()
	Case $803:End
	Case $401
		b=1-b
		FormatTextAreaText(t,0,0,0,b)
End Select
Forever



WolRon(Posted 2004) [#3]
clime me?


soja(Posted 2004) [#4]
i don't know what you're talking about ut =)


WolRon(Posted 2004) [#5]
I'll check this when I get home. Maybe it's because I'm setting the text color at the same time...


WolRon(Posted 2004) [#6]
You must be doing it wrong =)

Ahh, but the reason your code works and mine didn't is because you aren't adding additional lines!

Apparantly there is a bug in the FormatTextAreaText command when using it after adding more text to the textarea.


What I wanted to do was after adding a line to the text, to reset all lines to normal and then highlight only the last line. I couldn't get it to work.

This is what I had to do to make it work.

Function SelectLine(textline)
	For iter = 0 To TextAreaLen(ListingArea, 2)
		FormatTextAreaText ListingArea, 0, 0, 0, 0, iter, 1, 2
	Next
	FormatTextAreaText ListingArea, 200, 50, 50, 1, textline - 1, 1, 2
End Function


Note that I had to add a For loop to unformat every line individually.

Using the zero flag doesn't work if you've just added another line to the text.

Here's a code snippet that shows the problem. It will only switch the entire text to normal if a line ISN'T added.
w=CreateWindow("", 100,100,200,500)
t=CreateTextArea(0,0,ClientWidth(w), ClientHeight(w),w)
SetTextAreaText(t,"click me click me click me")
AddTextAreaText(t,Chr$(13)+Chr$(10)+"another line")
Repeat
Select WaitEvent()
	Case $803:End
	Case $401
		b=1-b
		If Rnd(100) < 25
			AddTextAreaText(t,Chr$(13)+Chr$(10)+"here's one more line")
		EndIf
		FormatTextAreaText(t,0,0,0,b)
End Select
Forever



skidracer(Posted 2004) [#7]
Yup, it's bugged (fixed it last week infact). New version of BlitzPlus is not too far away now, I would say next Friday but that would be inviting trouble.


WolRon(Posted 2004) [#8]
AWESOME! Can't wait to use it! I've been waiting for some features.