3.4.3. Check Box Example

This example shows how the cx-create-button-box, cx-create-toggle-button, cx-set-toggle-button and cx-show-toggle-button macros work. In the cx-create-button-box line the radio-mode argument is set to #f, which indicates that check boxes are being used, not radio buttons. Once the two check boxes have been created, the initial value of checkBox1 is set to #f via the statement (cx-set-toggle-button checkBox1 #f). Next, the value of a random Boolean variable isBool is set to #t via the (set! isBool #t) statement. After isBool is set to #t, it is next set to the value of checkBox1 through the use of a cx-show-toggle-button statement.

Finally, the value of checkBox2 is set to the value of isBool. Since checkBox2 isn’t checked when the dialog box is opened, we know that the cx-show-toggle-button statement works because it changed the value of isBool to #f. 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 checkBox1)
(define checkBox2)
(define isBool)

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

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

(define buttonBox (cx-create-button-box table "Button Box" 'radio-mode #f))

(set! checkBox1 (cx-create-toggle-button buttonBox "Check Box 1"))
(set! checkBox2 (cx-create-toggle-button buttonBox "Check Box 2"))

(cx-set-toggle-button checkBox1 #f)
(set! isBool #t)
(set! isBool (cx-show-toggle-button checkBox1))
(cx-set-toggle-button checkBox2 isBool)

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

To view additional examples of check boxes, see Comprehensive Examples.


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