3.2. Real Number Entry (cx-create-real-entry)

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

3.2.1. Description

This section discusses the ability to add a real number input field to your dialog box. A real number field is created using the cx-create-real-entry macro. The value of the real number field can be set using the cx-set-real-entry macro, and the value of a real number field can be obtained using the cx-show-real-entry macro.

3.2.2. Usage

This section explains the arguments used in the various real number entry field macros

3.2.2.1. cx-create-real-entry

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

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

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


3.2.2.2. cx-set-real-entry

(cx-set-real-entry realentry value)

ArgumentTypeDescription
realentryobjectThe variable used to create the real number entry field
valuerealThe value that you want to set the real number entry field to

3.2.2.3. cx-show-real-entry

(cx-show-real-entry realentry)

ArgumentTypeDescription
realentryobjectthe variable used to create the real number entry field

3.2.3. Real Number Entry Example

This example shows how the cx-create-real-entry, cx-set-real-entry and cx-show-real-entry macros work. Once the real number entry field has been created, the initial value of the field is set to 0.7 via the statement (cx-set-real-entry realField 0.7). Next, the value of that integer entry field is increased to 1.2 using another cx-set-real-entry statement. This statement also has a cx-show-real-entry statement nested in it in order to get the value already in the integer entry field and add 0.5.

By the time the cx-show-panel statement is read, the value of realField is now 1.2, so the number 1.2 appears in the real number entry field when the dialog box is opened. 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 realField)

(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! realField (cx-create-real-entry table "Real Entry Field"))

(cx-set-real-entry realField 0.7)

(cx-set-real-entry realField (+ 0.5 (cx-show-real-entry realField)))

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

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