Color Textarea

BlitzPlus Forums/BlitzPlus Beginners Area/Color Textarea

Does anyone know how to keep the textarea active when a color requester is active? I am trying to select a color and, when its selected, color the textarea text from then on with the selected color. But it's not working.

Include "b+.bb"

window=CreateWindow("Color Textarea",80,80,400,300,Desktop(),1+2)
textarea=CreateTextArea(10,50,ClientWidth(window)-20,ClientHeight(window)-60,window,0)
SetGadgetLayout textarea,1,1,1,1

syntaxfont=LoadFont("verdana",18,True)
SetTextAreaFont textarea,syntaxfont

button=CreateButton("COLOR",10,5,50,40,window)
SetGadgetLayout button,1,0,1,0

Repeat
	
	Select WaitEvent()
		Case EVENT_WINDOWCLOSE
		Select EventSource()
			Case window
				End
		End Select
		
		Case EVENT_GADGETACTION
		Select EventSource()
			Case button
			r=RequestColor()
			
			If r=True
				txt$=TextAreaText$(textarea)
				red=RequestedRed()
				green=RequestedGreen()
				blue=RequestedBlue()
				curtext=TextAreaCursor(textarea,1)
				If curtext<>0
				
					LockTextArea textarea
						FormatTextAreaText textarea,red,green,blue,0,curtext,Len(txt$)
					UnlockTextArea textarea
				
				EndIf
			EndIf
		End Select
	End Select
	
Forever