Interface Do loops

I set up 1 to 5 Edit boxes, depending on the circumstances, then go into a Do loop while the user fills each box and tabs from box to box. My intent is to exit the loop by hitting Return, as the sequence below shows:

CALL TC_Event(0,Event$,0,x1,x2)
If Event$="KEYPRESS" and x1=27 then Call Quit ! Escape hit
If Event$="KEYPRESS" and x1=13 then Exit Do ! Return hit

In one case it takes TWO hits of Return to exit, in another case it takes 3! I don't understand why even 2 hits should be needed, and 3 is still more mysterious.

Any ideas? I'm running Basic Silver 5.42 on a Mac.



EDIT fields


The TrueCtrl edit field absorbs keystrokes until you hit RETURN. This tells the edit field that you are done and that control can pass back to TC_event. I think that TAB has the same effect, and the focus will pass to the next edit field in the queue. If you don't terminate your edit field entry with either of these keystrokes then TC_event isn't monitoring the keyboard until you do, i.e. the first RETURN key will terminate the field and the second RETURN will be a true keystroke.

Big John

Edit fields

Not sure if TC_Event works as BigJohn says, but a simple

if d = 27 then...

works the way wanted--I think--at least it works for me!


TC_EDIT fields


It is not so much how TC_event works, but has more to do with the way TC_EDIT and TC_Txed work. In both cases, when you click inside the object and start to type, then that object absorbs all keystrokes until you indicate that you are done typing. You indicate this by typing RETURN or by clicking on another object such as a push button. Either way TC_event can now pick up keystrokes. Even if you use GET KEY it still will not register anything until TC_EDIT or TC_Txed have been deactivated.

Big John