This section describes how you can add a text entry field to your interface.
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.
This section explains the arguments used in the various text entry field macros
(cx-create-text-entry parent label row column)
Argument | Type | Description |
---|---|---|
parent | object | The name of the table that you are adding the text entry field to |
label | string | The name of the text entry field to be displayed on the GUI |
row | symbol/int | When added to a table, signifies the row that the text entry field is added to |
column | symbol/int | When 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.
(cx-set-text-entry text-var value)
Argument | Type | Description |
---|---|---|
text-var | object | The variable you used to create the text entry field |
value | string | The value you want to set the text entry field to |
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 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.