1

Why in the walkthrough titled 'text', does the text in the text field only get transmitted to the Gedit window when Enter is pressed. At which point in the code does it state 'When Enter is pressed transmit text in text field' or something to that extent?

I understand that it is when the event 'input' occurs, but what is the trigger for the event 'input' happen?

Link to walkthrough: https://www.youtube.com/watch?v=2s_WGOz6SAs&feature=youtu.be

Code generating the text field. enter image description here

Thank you

1 Answer 1

1

According to SPL's documentation about GTextField

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 GActionEvent 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .