Textfield not registering Return

BlitzPlus Forums/BlitzPlus Bug Reports/Textfield not registering Return

Righty, here's the code:
pseudo_group_window = CreateWindow("Select Name For Group",ClientWidth(Desktop())/2,ClientHeight(Desktop())/2,256,128,0,1)
pseudo_group_textfield = CreateTextField (16,16,ClientWidth(pseudo_group_window)-32,16,pseudo_group_window)
	
SetGadgetText (pseudo_group_textfield,"hello")

Repeat

	id=WaitEvent()

	DebugLog "Event = $"+Right$(Hex$(id),4) + "   "+EventSource() + "   "+EventData()


	Select id


		Case EVENT_GADGET
			If EventSource() = pseudo_group_textfield
				SetGadgetText (pseudo_group_label,EventData())
				If EventData() = 13
					Stop
					Exit
				EndIf
			EndIf

	End Select

Forever



When I press return in the text box I get an event ID of $104 (wtf?!) and EventSource and EventData of 0.

Windows XP Professional, SP2

Checkout the online help here:
http://www.blitzbasic.com/bpdocs/command.php?name=CreateButton&ref=gui_cat

The style flag needs to be 4 and then you can get the event from the button itself using:
If EventData() = 13

Actually i've set the style flag to 4 but i'm still unable to get the eventdata()=13

tfdTextFieldE=CreateTextField(8,146,150,20,TabPanel1,4)


You can use this code to capture a return key press

win = CreateWindow("Test Window - Default (15)",0,500,400,100,0) 
tbox = CreateTextArea(0,0,200,200,win)
; wait until the user closes one of the windows 
HotKeyEvent 28,0,$028,0,0,0,0,win; Set EventCode to $028 for enter key
Repeat
id = WaitEvent()
	Select id
		Case $028; Trap Enter key press here
			Stop
		Case $803
			Exit
	End Select
Forever 

End ; bye! 


The previous code actually doesn't work on a text field and you are right there is a BUG in the text field.. They do not return a eventsource ID when you select them, they only return something when you actually enter something in to them other than the enter key press. But once you enter something in to them you can trap the enter key.. Here is my revised code I've been working on trynig to figure out how to get this to work. Hope it helps you some.

dType = False
win = CreateWindow("test",0,500,400,400,0) 
tbox = CreateTextArea(0,0,200,100,win)
gbox = CreateTextField(0,102,200,20,win)
HotKeyEvent 28,0,$028,0,0,0,0,win 
Repeat
id = WaitEvent()
	Select id
		Case $028
			If (Not dType) id = 0:Goto badreturnkeypress
			Stop
		Case 260; ENTER Key press ID when in a text field
			If (Not dType) id = 0:Goto badreturnkeypress
			Stop
		Case $401
			dType = False
			If (Not dType) And EventSource() = tbox dType = True:Stop
			If (Not dType) And EventSource() = gbox dType = True
		Case $803
			Exit
.badreturnkeypress
	End Select
Forever 

End


The only problem is if the user didn't press any key on the gadget - it will not know which gadget is in!

As i cannot get event activity for user selecting a gadget i'm unable to try get around this problem!

But thanks anyway - If the user would not change gadget with mouse i might be able to cycle the gadgets in a predefined manner...

I know there is tab - but tab does'nt generate any event either and i must process the contents of the string conditionally or do maths operation depending on the textfield...

I don't see a problem with using my solution.. Simply keep to sets of variables and after an ENTER is detected compare the two sets of variables to see what data was changed and then act accordingly.

But I do think they need to fix this bug so we don't need to add all the extra code to do something that should be very simple.

The code i have needs to check the textfield contents on the press of the return key, and if valid it will perform some actions or operations and activate the corresponding textfield result.

I did a workaround, and set a gadget variable that keeps track of all relevant events and is updated to the relevant gadget use by the use of the escape key.

Of course the user has to type something into the gadget the first time he uses. Selecting the gadget does not produce any eventid()...

Still it was best if the return key press eventid produced more data - at least the eventsource() data...

I hope I understood your problem in the right way. Your problem is, that, after an update I suspect, the textfields don't register EventData 13 anymore when the return-key is pressed. I had the same problem after an update from version 1.11 to version 1.45 and I solved it in this way:
-Create a Button next to the textfield with style flag 4.
-If you don't want anybody to see it, enter 0 for width and height.
-When someone presses return while the textfield is selected, the button will return EventID $401 and its eventsource, because of the style flag 4, a new one. Read all about this flag at the online help on
http://www.blitzbasic.com/bpdocs/command.php?name=CreateButton&ref=gui_cat
I hope I could help you.