gui validation

BlitzMax Forums/BlitzMax Programming/gui validation

brains not working, why isnt this?


SuperStrict

Global win:tgadget=CreateWindow("a window!",50,50,120,80,Null,WINDOW_TITLEBAR)
Global edit1:tgadget=CreateTextField(10,10,90,20,win)

AddHook EmitEventHook,myhook


While TextFieldText(edit1)<>"EXIT"

	PollSystem()
	Delay(100)

Wend


End


Function MyHook:Object( id:Int,data:Object,context:Object )
	Local p:Int
	
	While PollEvent()<>0

	Print CurrentEvent.tostring()
	If EventID()=EVENT_WINDOWCLOSE Then End

	If EventID()=EVENT_GADGETACTION Then
		Local s:String
		s=TextFieldText(edit1)
		s=Upper(s)
		SetGadgetText edit1,s
	EndIf

	Wend
	
	Return data

End Function



It is but the first bit of text is used to activate the gadget.
e.g. type in 'h' = 'h' but 'hh' = 'HH'.
If that makes sense.
<edit> Not sure why ActivateWindow doesn't make it work OK though.

which means it isnt working!!

.. but you didn't have an ActivateWindow command anyway.
<edit>
Hmmm... second thoughts it's just not working. Should redrawgadget update the field (doc states "The RedrawGadget command causes the gadget to be redrawn by the underlying
Operating System and is not guaranteed to happen immediately.
")?
Will setgadgettext be actioned immediately or on some OS command (movewindow) which activates the gadget redraw?

it seems to be a problem with passing the unhandled gadget events like window move etc, these and other events and an unkonown event seem to que up...

can anyone see whats going on?

Chris,
This works.
SuperStrict

Global win:tgadget=CreateWindow("a window!",150,150,120,80,Null,WINDOW_TITLEBAR)
Global edit1:tgadget=CreateTextField(10,10,90,20,win)

AddHook EmitEventHook,myhook
ActivateGadget edit1 '<---------need to activate

While TextFieldText(edit1)<>"EXIT"

	PollSystem()
	Delay(100)

Wend


End


Function MyHook:Object( id:Int,data:Object,context:Object )
	Local p:Int
	Local Event:TEvent=TEvent(Data) '<---------added	
	Print TextFieldText(edit1)'<---------for debugging

	If Event.ID=EVENT_WINDOWCLOSE Then End'<---------use object.ID

	If Event.ID=EVENT_GADGETACTION Then
		Local s:String
		s=TextFieldText(edit1)
		s=Upper(s)
		SetGadgetText edit1,s
	EndIf
	
	Return data

End Function

I'm guessing calling pollevent from eventhook could be dodgy

hmm odd that, wonder why you cant pollevent in an event hook...