3.3. Text Entry (cx-create-text-entry)

This section describes how you can add a text entry field to your interface.

3.3.1. Description

This section discusses the ability to add text entry fields to your dialog box. Text entry fields are created with the cx-create-text-entry macro. The text of a text entry field can be set using the cx-set-text-entry macro, and can be obtained using the cx-show-text-entry macro.

3.3.2. Usage

This section explains the arguments used in the various text entry field macros

3.3.2.1. cx-create-text-entry

(cx-create-text-entry parent label row column)

ArgumentTypeDescription
parentobjectThe name of the table that you are adding the text entry field to
labelstringThe name of the text entry field to be displayed on the GUI
rowsymbol/intWhen added to a table, signifies the row that the text entry field is added to
columnsymbol/intWhen added to a table, signifies the column that the text entry field is added to

Note:  The row and column attributes are optional. If you leave out one or both of these attributes the text entry field will be added to the first row/column of the parent attribute and overwrite anything that is already in that spot.


3.3.2.2. cx-set-text-entry

(cx-set-text-entry text-var value)

ArgumentTypeDescription
text-varobjectThe variable you used to create the text entry field
valuestringThe value you want to set the text entry field to

3.3.2.3. cx-show-text-entry

(cx-show-text-entry textentry)

ArgumentTypeDescription
text-varobjectThe variable you used to create the text entry field

3.3.3. Text Entry Example

This example shows how the cx-set-text-entry and cx-show-text-entry macros work. Once the text entry field has been created, the initial value of the field is set to Starting text via the statement (cx-set-text-entry txtField "Starting text"). Next, the value of a random string isString is set to This is different text via the (set! isString "This is different text") statement. After isString is set to This is different text, it is next set to the value of the text entry field through the use of a cx-show-text-entry statement.

Finally, the value of the text entry field is set to the value of isString. Since the text entry field says Starting text when the dialog box is opened, we know that the cx-show-text-entry statement works because it changed the value of isString to Starting text. This dialog box does not do anything when the OK button is clicked because we have substituted Boolean values for the apply-cb and update-cb arguments, which would normally be function calls. For more information on the apply-cb and update-cb functions, see cx-create-panel.

(define (apply-cb) #t)
(define update-cb #f)

(define table)
(define txtField)
(define isString)

(define my-dialog-box (cx-create-panel "My Dialog Box" apply-cb update-cb))

(set! table (cx-create-table my-dialog-box "This is an example Dialog Box"))

(set! txtField (cx-create-text-entry table "Text Entry Field"))

(cx-set-text-entry txtField "Starting text")
(set! isString "This is different text")
(set! isString (cx-show-text-entry txtField))
(cx-set-text-entry txtField isString)

(cx-show-panel my-dialog-box)

To view additional examples of string entry fields, see Comprehensive Examples.