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.


Release 18.2 - © ANSYS, Inc. All rights reserved.