modify callback is called when a change is detected in the field

Discussion in 'Cadence' started by PolyPusher, Jul 28, 2009.

  1. PolyPusher

    PolyPusher Guest

    Hi All,

    I am trying to write code to sort a list and wish to have the
    hiCreateStringField modifyCallback detect changes in the field and
    call the procedure for the sort(dynamically as user types in).

    I have for the form below and I cut and paste some Cadence
    documentation under that.

    Thank you in advance for any help(example would be great!),
    Eric

    ;=============================================
    ;section below defines form
    ;=============================================

    EFWindowid=hiCreateIntField(
    ?name 'EFWindowid
    ?prompt "Window Number"
    ?value EFwindow_number
    ?callback "EFnew_window()"
    ?invisible t
    )

    ;===================need help here==================
    EFSortBy = hiCreateStringField(
    ?name 'EFSortBy
    ?prompt "Enter string to sort data by"
    ?callback "EFSortByString()"
    ?modifyCallback
    ?editable t
    ?value ""
    );as each character is entered, use the t_modifyCallback argument.
    ;==============================================

    EFSelectOrProbe = hiCreateRadioField(
    ?name 'EFSelectOrProbe
    ?prompt "Probe or Schematic Select"
    ?value "Probe"
    ?defValue "Probe"
    ?choices list("Probe" "Select")
    )

    EFDataSingleClick = hiCreateRadioField(
    ?name 'EFDataSingleClick
    ?prompt "Data type to perform Probe or Select"
    ?value "Net"
    ?defValue "Net"
    ?choices list("Instance" "Cellname" "InstTerm" "Net")
    )

    EFDeselectCurr = hiCreateButtonBoxField(
    ?name 'EFDeselectCurr
    ?prompt " "
    ?choices '("Undo" "Clear" "Auto Sort" "Refresh" "Reverse")
    ?callback '("EFDeselectCurrentCB()" "EFDeselectAllCB()"
    "EFAutoSortCB()" "EFRefreshForm()" "EFReverseList()")
    )

    EFNetsBox = hiCreateListBoxField(
    ?name 'EFListBoxField
    ?prompt " "
    ?choices EFNet_list
    ?value nil
    ?multipleSelect nil
    ?changeCB "EFprobe()"
    ?doubleClickCB "EFprobeandzoom()"
    ?CBOnReselect t
    ?numRows length(EFNet_list)
    )

    ;;; defines the form

    hiCreateAppForm(
    ?name 'EFInstanceNetsForm
    ?formTitle "Instance Viewer. Data Format:Instance.Cellname.Term
    (Pin) - Net Name"
    ?buttonLayout 'OKCancel
    ?callback "EFSortExecutionCB(hiGetCurrentForm())"
    ?fields
    list(
    EFWindowid
    EFSortBy
    EFSelectOrProbe
    EFDataSingleClick
    EFDeselectCurr
    EFNetsBox
    )
    ?help ""

    ) ; hiCreateAppForm

    hiDisplayForm(EFInstanceNetsForm)


    t_modifyCallback
    SKILL function to be executed whenever any change is made in the
    text field, for example, by typing or pasting. The modify callback is
    called when a change is detected in the field but before the change is
    displayed.

    The modify callback function is passed the following arguments:

    s_fieldName t_latestTextValue g_sourceOfChange

    where s_fieldName is the symbol of the field in which the change
    was made, t_latestTextValue is the latest text value of the field, and
    g_sourceOfChange is t or nil where t indicates that the change was
    made programmatically (by changing the value of the field) and nil
    indicates that the change was made by a user action.

    The modify callback function should return the following:

    t | nil | value

    If the modify callback function returns t, the changes made to the
    field are allowed and are displayed as they are entered. If the
    function returns nil, the changes made to the field are not allowed
    and are not displayed--the original value of the field is retained. If
    the function returns some other value, it must be a string. This value
    replaces the current value of the field.

    t_focusInCallback
    SKILL function to be executed whenever the field comes into
     
    PolyPusher, Jul 28, 2009
    #1
  2. PolyPusher wrote, on 07/28/09 20:07:
    .... snipped mercilessly ...


    Eric,

    I'm not entire sure what you're asking here, but a modifyCallback would be done
    like this:

    EFSortBy = hiCreateStringField(
    ?name 'EFSortBy
    ?prompt "Enter string to sort data by"
    ; ?callback "EFSortByString()"
    ?modifyCallback "EFSortByStringModifyCB"
    ?editable t
    ?value ""
    );

    And here's an example function:

    procedure(EFSortByStringModifyCB(field value source)
    printf("FIELD is %L\nVALUE is %L\nSOURCE is %L\n"
    field value source)
    t
    )

    I wasn't entirely sure what you meant by "string to sort data by" so I couldn't
    implement the sort itself - I'm assuming you can do this.

    In this case, the callback always returns t - to say that the characters being
    typed in are acceptable. Within the callback you can do whatever you want though.

    Regards,

    Andrew.
     
    Andrew Beckett, Jul 28, 2009
    #2
  3. PolyPusher

    PolyPusher Guest

    That answered my question!
    Thank you very much Sir Andrew,
    Eric
     
    PolyPusher, Jul 29, 2009
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.