According to SPL's documentation about
GTextField GTextField(int nChars);
Creates a text field capable of holding
nChars characters. Assigning
an action command to the text field causes it to generate an action
event whenever the user types the ENTER key. Usage:
field = newGTextField(nChars);
typedef GInteractor GTextField;
This interactor subtype represents a text field for entering short
text strings. Hitting enter in a text field generates a
if the text field has a nonempty action command. Usage:
str = getText(field);
The pressing of Enter to generate the
GActionEvent is somewhere inside the implementation of of ginteractors.c of the SPL library.
As a programmer using functions others have written, you don't have to know how the function does something, but what does this function do, when you comply to its demands. That's what is called abstract programming. Read the documentation, give as input what it needs, and then it will give you the expected output. In this case you have to enter some text and then press Enter.
If this answers your question please accept it by clicking the gray check-mark to the left, so that it becomes green. You can also vote it up by pressing the up arrow above the check-mark. And don't forget to keep coding!
SPL library source: https://github.com/cs50/spl/tree/master/doc