KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Use GOTO OBJECT Command to Dynamically Set Next Object in Entry Order
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: December 12, 2022

When it comes to filling out forms on the computer, it is nice to flow from one data-entry object to another for feasible user experience. For example, when a user is done filling out his or her name in a text input box and presses the Tab button, the cursor would automatically be set to the next input. This can be simulated in a 4D application by using the GOTO OBJECT command.

You can use the GOTO OBJECT command to shift the user’s focus to the next data-entry form object or jump to any specified input object.


Example: Jumping from drop-down menu to a specific input box

// Drop-Down Menu Object Method
// after user selects option, jumps to specified input box \
depending on option selected

Case of
   : (Form event code=On Clicked) // user selects option
   $option:=OBJECT Get pointer(Object named; "dropdownMenu")->
   If ($option=4)
   GOTO OBJECT(*; "Input") // "Other” is chosen, jump to next input box
   Else
   GOTO OBJECT(*; "Input1") // any other item is chosen, jump to question #2
   End if
End case


When the user selects “Other”, the cursor jumps to the next immediate input box:


When the user selects any other item, the cursor jumps to the next question:


Rather than using the POST KEY/POST EVENT commands, the GOTO OBJECT command is more powerful in that you can specify which form object to jump to; moreover, the POST KEY/POST EVENT commands can lead to unintended outcomes, especially with keys commonly used in different contexts.