SKILL Q: enable form field dynamically

B

Bernd Fischer

Guest
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
)
)
 
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 )

)
 
You should look at hiEnableFormButton() and hiSetFieldEnabled(). I've
not used them yet, but I am told these will do what you want.

On Tue, 20 Jan 2004 17:54:31 +0100, Bernd Fischer
<bernd.fischer@xignal.de> wrote:

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 )

)
 
In article <400D58A9.2080506@xignal.de> Bernd Fischer <bernd.fischer@xignal.de> writes:
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?
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
(phz@seeheader.nospam)

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

- Herb Caen
 
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")
)



On Tue, 20 Jan 2004 17:54:31 +0100, Bernd Fischer <bernd.fischer@xignal.de>
wrote:

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 )

)
--
Andrew Beckett
Senior Technical Leader
Custom IC Solutions
Cadence Design Systems Ltd
 
Hi Guys,

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

Bernd

Andrew Beckett wrote:
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")
)



On Tue, 20 Jan 2004 17:54:31 +0100, Bernd Fischer <bernd.fischer@xignal.de
wrote:


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 )

)


--
Andrew Beckett
Senior Technical Leader
Custom IC Solutions
Cadence Design Systems Ltd
 

Welcome to EDABoard.com

Sponsor

Back
Top