SKILL Q: enable form field dynamically

Discussion in 'Cadence' started by Bernd Fischer, Jan 20, 2004.

  1. Hi,

    I want to enable disable a button box form field
    dynamically depending on the value of a cyclic field
    of the same form.
    Something similar to the snipped code attached, but this does not
    work! Any ideas?

    FYI the form was only created once.

    Thanks Bernd


    l_windowSetupFields =
    tconc(
    l_windowSetupFields
    list(
    hiCreateCyclicField(
    ?name 'r_layoutWindowField
    ?choices cons( "New" l_layoutWindowIdList )
    ?prompt "Layout window"
    ?value "New"
    )
    ( x_xInitalPos:( x_yInitalPos + 40 ) )
    ( x_setupFieldWidth:25 )
    160
    )
    )


    l_windowSetupFields =
    tconc(
    l_windowSetupFields
    list(
    hiCreateButtonBoxField(
    ?name 'r_createField
    ?prompt " "
    ?choices '( " Create " )
    ?callback list( "printf( \"DEBUG\" )" )
    ?enabled
    hiGetCurrentForm( )~>r_tabField~>page1~>r_layoutWindowField->value == "New"
    )
    ( ( x_xInitalPos + 280 ):( x_yInitalPos + 40 ) )
    ( 100:25 )
    10
    )
    )
     
    Bernd Fischer, Jan 20, 2004
    #1
  2. A more usable (cut and paste example).

    It can not be creating the form every time new
    when the cyclic field value has changed to
    enable/disable the button box field?

    Bernd


    procedure( BFcreateTestForm( )
    let( ( r_testCyclicField r_testButtonBoxField )

    r_testCyclicField =
    hiCreateCyclicField(
    ?name 'r_testCyclicField
    ?choices list( "One" "Two" )
    ?prompt "Test Cyclic Field"
    ?value "One"
    )

    r_testButtonBoxField =
    hiCreateButtonBoxField(
    ?name 'r_testButtonBoxField
    ?prompt " "
    ?choices list( " Test " )
    ?callback list( "printf( \"This si a test.\" )" )
    ?enabled GBtestForm->r_testCyclicField->value == "One"
    )

    hiCreateAppForm(
    ?name 'GBtestForm
    ?formTitle "Test"
    ?fields list( r_testCyclicField r_testButtonBoxField )
    )

    )
    )


    procedure( BFdisplayTestForm( )

    unless( boundp( 'GBtestForm ) && GBtestForm
    BFcreateTestForm( )
    )

    hiDisplayForm( GBtestForm )

    )
     
    Bernd Fischer, Jan 20, 2004
    #2
  3. You should look at hiEnableFormButton() and hiSetFieldEnabled(). I've
    not used them yet, but I am told these will do what you want.
     
    Diva Physical Verification, Jan 20, 2004
    #3
  4. Bernd Fischer

    Guest Guest

    Your ?enabled value is evaluated once, at the time the create field code is
    evaluated, so of course it doesn't work dynamically.

    You need to use the value change callback of the one field to enable/disable
    the other field.

    -Pete Zakel
    ()

    It's a funny thing - you work all your life toward a certain goal
    and then somebody moves the posts on you.

    - Herb Caen
     
    Guest, Jan 20, 2004
    #4
  5. Bernd,

    You need to use a callback and invoke hiSetFieldEnabled() to change the
    enabled field. In your code the ?enabled flag is only set at the time of
    form creation.

    Here's an example update.

    Andrew.


    procedure( BFcreateTestForm( )
    let( ( r_testCyclicField r_testButtonBoxField )

    r_testCyclicField =
    hiCreateCyclicField(
    ?name 'r_testCyclicField
    ?choices list( "One" "Two" )
    ?prompt "Test Cyclic Field"
    ?value "One"
    ?callback "BFtestCyclicFieldCB(hiGetCurrentForm())"
    )

    r_testButtonBoxField =
    hiCreateButtonBoxField(
    ?name 'r_testButtonBoxField
    ?prompt " "
    ?choices list( " Test " )
    ?callback list( "printf( \"This si a test.\" )" )
    ?enabled t
    )

    hiCreateAppForm(
    ?name 'GBtestForm
    ?formTitle "Test"
    ?fields list( r_testCyclicField r_testButtonBoxField )
    )

    )
    )


    procedure( BFdisplayTestForm( )

    unless( boundp( 'GBtestForm ) && GBtestForm
    BFcreateTestForm( )
    )

    hiDisplayForm( GBtestForm )

    )

    procedure(BFtestCyclicFieldCB(form)
    hiSetFieldEnabled(form->r_testButtonBoxField
    form->r_testCyclicField->value=="One")
    )
     
    Andrew Beckett, Jan 20, 2004
    #5
  6. Hi Guys,

    Thanks, of course the callback does the trick,
    this was also my overnight thought.

    Bernd
     
    Bernd Fischer, Jan 21, 2004
    #6
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.