Product Documentation
Cadence User Interface SKILL Reference
Product Version IC23.1, September 2023

Function Object Callbacks

The syntax of a function object callback is the following:

<callback> (o_field g_scope @rest_args)

where,

Examples

In this example, the function make_radians_degrees_fields() creates two type-in fields, Radians and Degrees with a local callback converter. The callback is used to set the value of the Radians field based on the value of the Degrees field and vice versa. Also, in this example, the callback is not defined in the global namespace and that there is no need to know where the two type-in fields are to be placed.

(defun converter (field scope)
  (let ((scale 180.0/3.14159265))
    (caseq field->hiFieldSym
    (radians scope->degrees->value = (round field->value * scale))
    (degrees scope->radians->value = field->value / scale)
    (t (assert "this shouldn't happen")))))
      
(defun make_radians_degrees_fields ()
  (list
    (hiCreateFloatField ?name 'radians ?callback 'converter ?prompt "Radians" ?value 0.0)
    (hiCreateIntField ?name 'degrees ?callback 'converter  ?prompt "Degrees" ?value 0)))
;; create the form
Form2D = hiCreateAppForm(
                ?name           'Form2D
                ?formTitle      "R2D&D2R Converter"
                ?fields (make_radians_degrees_fields)
             )
hiDisplayForm(Form2D)

In this example, the function list_png_files() searches for all the .png files in the given directory, lists them in a cyclic field, and prints the filename when an icon is selected from the cyclic field.

(defun list_png_files ( dir )
  (let ((png_files (rexMatchList ".png$" (getDirFiles dir)))
        (png_table (makeTable "icon to .png file name" nil)))
    ;; establish mapping
    (mapcar (lambda (x) png_table[ (hiLoadIconFile x 24 24) ] = x) png_files)
    (hiDisplayForm
     (hiCreateAppForm
      ?name 'png_list_form ?formTitle "PNG List" ?buttonLayout 'Close
      ?fields (list (hiCreateCyclicField
                     ?name 'icons ?prompt "Icons" ?choices png_table->?
                     ?callback (lambda (field scope item)
                                 (printf "selected item is %L\n" png_table[ item]))))))))
(list_png_files (prependInstallPath "../../share/cdssetup/icons/24x24"))

Return to top
 ⠀
X