canvas - textfield problem

BlitzPlus Forums/BlitzPlus Programming/canvas - textfield problem

hub(Posted 2003) [#1]
Hi, i've two questions !

1) The following example show you my problem. If you use directly the cursor key to drawing into the canvas, it works, no problem. Now, if you write something into the textfield or use the button you can't drawing into the canvas !!!

2) how to perform 'SetGadgetText TextField2, TextFieldText(TextField1)' only if you enter some text into
TextField1 and press the enter key (without press the button).

Many thanks for your help !




Win1 = CreateWindow("Window1",81,133,250,280,Desktop(),3)
Canvas1 = CreateCanvas(12,13,200,120,Win1,0)
TextField1 = CreateTextField(11,142,100,20,Win1,0)
SetGadgetText TextField1,"Blitz+"
TextField2 = CreateTextField(12,170,100,20,Win1,0)
SetGadgetText TextField2,"Nothing"
Button1 = CreateButton("Button",15,198,100,20,Win1,0)

SetBuffer CanvasBuffer (Canvas1)
Color 255,255,255
x = 100 : y=100
Rect x,y,2,2
FlipCanvas (Canvas1)

While WaitEvent()<>$803

	Select EventSource()
	
		Case button1
		
			SetGadgetText TextField2, TextFieldText(TextField1)  
	
	End Select

		
	If KeyDown(200) Then y = y - 1
	If KeyDown(208) Then y = y + 1
	If KeyDown(203) Then x = x - 1
	If KeyDown(205) Then x = x + 1
	
	SetBuffer CanvasBuffer (Canvas1)
	Color 255,255,255
	Rect x,y,2,2
	FlipCanvas (Canvas1)

Wend



CS_TBL(Posted 2003) [#2]
question 2:

app=CreateWindow("",0,0,320,320)

t1=CreateTextField(0,0,256,32,app)
t2=CreateTextField(0,64,256,32,app)

quit=False
Repeat 
	WaitEvent()
	If EventID()=$803 quit=True
	
	If EventID()=$401
		If EventSource()=t1
			If EventData()=13	; ascii code of [enter]
				SetGadgetText t2,TextFieldText$(t1)
			EndIf
		EndIf
	EndIf
	
Until quit
End



question 1 ... I thought I knew that one too.. guess I don't remember how.. anyone..?


CS_TBL(Posted 2003) [#3]
btw.. just a detail, you might want to draw according to a timer..

blah=createtimer(30) ; put this line somewhere in the beginning of your app, in the beginning.. not in the mainloop



and put your keychecks between:

if eventid()=$4001
    ; if keydown(200) etc....
endif

[/code]


hub(Posted 2003) [#4]
Thanks !

Is somebody have a reply for 1) ?


assari(Posted 2003) [#5]
put
ActivateGadget canvas1
before your keydown(200) statement


hub(Posted 2003) [#6]
Yes, thanks !