TextFieldText to TextFieldText to button

BlitzMax Forums/BlitzMax GUI Programming/TextFieldText to TextFieldText to button

I'm working on a login form, and like every login window have 2 textbox, so i wish that on press_enter(tbUsername) the cursor jump to tbPassword, and then transfer the focus on the "login" button.

the problem, as i read here on the forum, is about GetLostFocus, but actualy i'm not so good in blitzScripting to work around this problem, so wish to find some tips/help here :-\

1. there is no scripting in blitz. its programming
2. You have to react to the event_keydown and the sender to make it jump from gadget to gadget

Just thought about a different approach using textareas...

SuperStrict

Global	TextPassword1:TGadget
Global	TextUser1:TGadget
Global	Login:TGadget

Local Window1:TGadget = CreateWindow:TGadget("Login",340,178,215,162,Null,WINDOW_TITLEBAR|WINDOW_TOOL |WINDOW_CLIENTCOORDS )
	Local Label3:TGadget = CreateLabel:TGadget("Secured area!",10,12,80,18,Window1:TGadget,Null)
	Local SP4:TGadget = CreateLabel:TGadget("SP4",2,31,211,23,Window1:TGadget,LABEL_SEPARATOR)
	Local Cancel:TGadget = CreateButton:TGadget("Cancel",131,138,75,23,Window1:TGadget,BUTTON_CANCEL)
	Local Label1:TGadget = CreateLabel:TGadget("User name:",10,55,67,16,Window1:TGadget,Null)
	Local Label2:TGadget = CreateLabel:TGadget("Password:",10,96,80,16,Window1:TGadget,Null)
	TextPassword1:TGadget = CreateTextArea:TGadget(106,87,100,25,Window1:TGadget,Null)
		DisableGadget( TextPassword1:TGadget )
		SetTextAreaText( TextPassword1:TGadget , "" )
		SetGadgetFilter( TextPassword1:TGadget, Filter )
	TextUser1:TGadget = CreateTextArea:TGadget(106,46,100,25,Window1:TGadget,Null)
		SetTextAreaText( TextUser1:TGadget , "" )
		SetGadgetFilter( TextUser1:TGadget, Filter )
	Login:TGadget = CreateButton:TGadget("Login",9,138,75,23,Window1:TGadget,BUTTON_OK)
		DisableGadget( Login:TGadget )

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			Select EventSource()
				Case Window1	Window1_WC( Window1:TGadget )
			End Select

		Case EVENT_GADGETACTION
			Select EventSource()
				Case Cancel	Cancel_GA( Cancel:TGadget )
				Case TextPassword1	TextPassword1_GA( TextPassword1:TGadget )
				Case TextUser1	TextUser1_GA( TextUser1:TGadget )
				Case Login	Login_GA( Login:TGadget )
			End Select

	End Select
Forever

Function Window1_WC( Window:TGadget )
	DebugLog "Window Window1 wants to be closed"
'	HideGadget( Window:TGadget )

	End
End Function

Function Cancel_GA( Button:TGadget )
	DebugLog "Button Cancel was pressed"
	
End Function

Function TextPassword1_GA( TextArea:TGadget )
	DebugLog "TextArea TextPassword1 was modified"
	EnableGadget(Login)
If TextAreaLen( textarea:TGadget,TEXTAREA_Lines ) >1 Then 
	Local t$=TextAreaText(TextArea,0,1,TEXTAREA_LINES)
	SetTextAreaText(TextArea, t[..t.length-1])
	ActivateGadget(Login)
	Login_GA( Login:TGadget )
End If

End Function

Function TextUser1_GA( TextArea:TGadget )
	DebugLog "TextArea TextUser1 was modified"
	EnableGadget(TextPassword1)
If TextAreaLen( textarea:TGadget,TEXTAREA_Lines ) >1 Then 
	Local t$=TextAreaText(TextArea,0,1,TEXTAREA_LINES)
	SetTextAreaText(TextArea, t[..t.length-1])
	ActivateGadget(TextPassword1)
End If

End Function

Function Login_GA( Button:TGadget )
	DebugLog "Button Login was pressed"
	If TextAreaText(TextUser1)<>"user"
	SetTextAreaColor( TextUser1:TGadget,255,0,0,True)
Else
	SetTextAreaColor( TextUser1:TGadget,255,255,255,True)

End If
If TextAreaText(TextPassword1)<>"password"
	SetTextAreaColor( TextPassword1:TGadget,255,0,0,True)
Else
	SetTextAreaColor( TextPassword1:TGadget,255,255,255,True)

End If
End Function

Function Filter:Int( event:TEvent,context:Object )
	DebugLog "TextArea TextPassword1 filtering text input: "+Chr(Event.data)+"="+Event.Data+","+Event.Mods
	Select Event.ID
	    Case EVENT_KEYDOWN
	    Case EVENT_KEYCHAR
	        If Event.Data = KEY_TAB Then Return False
	End Select
	Return True
End Function