Controlling the Tab Cycle in the last field of a form

I have a form with several text editor objects. Each one has Include in Tab Cycle checked. But when I finish the last one on the page, I don’t want to go back to the top; I just want all of them deselected. I tried putting a closeactiveobject statement in the procedure, which is triggered when the editor is finished editing. That did not prevent the top text editor from be active.

Does anyone know how to do this?

In the Options panel for the last Text Editor set the Termination Keys to Return & Tab. Keep the Tab Option set to Include in Tab Cycle. In the Procedure Trigger section check End Editing. In the Procedure panel put:

wait 0
closeactiveobject

This seems to do what you have described. There may be other problems that will surface but only further testing will tell. Hope this helps.

I think Gary’s solution is probably ok.

Hi Gary, thanks for this suggestion. I did as suggested. If I tab into the last field, then add the required info, then press return, the dialog acts as I would like. But if I tab out of the last field, the cursor still goes to and activates the top Text Editor. I am not sure if this is what you observed also. If I could get the tab to act the same as the return, life would be just right.

I have additional code in the last text editor procedure: first error checking to ensure the value entered is a valid floating point number, and if that is true and other variables are also assigned valid values, then the procedure makes a button the default button and turns off disable for that button, so pressing return closes the dialog and proceeds with the calling procedure. I wouldn’t have thought that the other code would affect the last part of the procedure, i.e. the wait and closeactiveobject statement.

Of course, this is a very minor thing, but I am trying to perfect the interaction with this dialog so there are no extra clicks or tabs etc. It may be as close as possible now.

To start with, I have not been able to detect any difference using rather simple code when terminating editing on the last Text Editor using tab or return. I did some experimenting with some more robust methods to control the editing ability of the Text Editors using a fileglobal to toggle editing on and off when needed.

Here is what I tried (and, yes, it gets pretty hairy). First in the Form Properties pane I put code to define a variable that I used to to control whether the Text Editors were editable or not.

image

I then created a procedure I called unTab to contain my code for the last Text Editor:

return

return

startEditing:
    if editLock=1
        wait 0
        closeactiveobject
    endif
    editLock=1
    showvariables editLock
    return
    
finishEditing:
    editLock=1
    showvariables editLock
    wait 0
    closeactiveobject
    return

In the Code pane for the last Text Editor I just called this unTab procedure. In the Code panes of all the other Text Editors I used this code:

return

startEditing:
	if editLock=1
		wait 0
		closeactiveobject
	endif
	return

I also added a Edit Reset button that will unlock editing for all the Text Editors if wanted by changing the value of the editLock variable back to 0 or unlocked. Now whenever the form is brought to the front the editLock variable is set to unlocked automatically.

Here is my example form in action:

I realize this is kinda “out there” but it kept me occupied for a while this morning. :sunglasses:

Thanks, Gary. I am amazed at your ability to solve this. I might come back to this later when I want to do some final touches on the interface. I was hoping there was a simple answer. Oh well.

I have a thought for another possible way to address this. I haven’t tested it, but I will throw it out there.

Instead of trying to trap the tab key in the finish editing code, you could trap it in advance with a hotkey. You could set up the hotkey in the start editing code for the last Text Editor object. Then you could simply make closeactiveobject the code triggered by the hot key. Oh, you would also need to have this code cancel the hotkey (in fact you need to do this no matter how the text editor is exited). I would use window as the scope of the hot key.