Updating string field instantaneously

D

Dmitriy Shurin

Guest
I have a button field which has to update a string field in a form. The
string field updates, but the value can be seen only after i reenter the
form. it is very inconvenient, because i can't see the result
immediately. this is the code i have so far

;;;Creation of "Select" button for Vin(+)
VinPosBut=hiCreateButton(
?name 'VinPosBut
?buttonText "Select"
?callback "VinPosStr->value=objSelect()"
)

;;;Creation of Vin(+) input string field
VinPosStr=hiCreateStringField(
?name 'VinPosStr
?prompt "Vin(+)"
?editable t
)

;;;Get a net
procedure(objSelect()
let((temp)
geDeselectAll()
geSingleSelectPoint()
temp=car(geGetSelSet())
when((temp->objType=="line")|| (temp->objType=="label")
temp=strcat("/" temp->net->name)
);end of when
geDeselectAll()
temp
);end of let
);of procedure

is there anything i do wrong?


--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
 
On Wed, 6 Oct 2004 19:16:07 +0000 (UTC), "Dmitriy Shurin"
<shurin@bgumail.bgu.ac.il> wrote:

I have a button field which has to update a string field in a form. The
string field updates, but the value can be seen only after i reenter the
form. it is very inconvenient, because i can't see the result
immediately. this is the code i have so far

;;;Creation of "Select" button for Vin(+)
VinPosBut=hiCreateButton(
?name 'VinPosBut
?buttonText "Select"
?callback "VinPosStr->value=objSelect()"
)
snipped
is there anything i do wrong?
Yes, you should make your callback for the button start from the
formId, rather then just the field. I'm not 100% sure as to why this
has to be, but it certainly doesn't work properly otherwise. I must
admit I've always done it this way, and rarely would have the fields
stored in global variables, so wouldn't have seen the issue you're
seeing.

Below is the modified code (I added a little to make the example
complete enough to be able to run):

;;;Creation of "Select" button for Vin(+)
VinPosBut=hiCreateButton(
?name 'VinPosBut
?buttonText "Select"
; use the form to get the field - update it that
; way
?callback "dmitriy->VinPosStr->value=objSelect()"
)

;;;Creation of Vin(+) input string field
VinPosStr=hiCreateStringField(
?name 'VinPosStr
?prompt "Vin(+)"
?editable t
)

hiCreateAppForm(
?name 'dmitriy
?formTitle "Dmitriy form"
?fields list(VinPosBut VinPosStr)
)

;;;Get a net
procedure(objSelect()
let((temp)
geDeselectAll()
geSingleSelectPoint()
temp=car(geGetSelSet())
when((temp->objType=="line")|| (temp->objType=="label")
temp=strcat("/" temp->net->name)
);end of when
geDeselectAll()
temp
);end of let
);of procedure

hiDisplayForm(dmitriy)

In other words, I created the form itself, stored in a variable
dmitriy (it should really have a sensible, prefixed, global variable
name), and then referenced the form in the callback for the button.
Doing this updates the field as soon as you've made the selection.

Best Regards,

Andrew.
 
Think of the hiCreateButton as returning a template for a field that is
used to create an actual field in the form, but is not referenced once
the form is created. This would explain why you have to modify the form
field instead of the field definition.

On Wed, 13 Oct 2004 16:08:03 +0100, Andrew Beckett
<andrewb@DcEaLdEeTnEcTe.HcIoSm> wrote:

On Wed, 6 Oct 2004 19:16:07 +0000 (UTC), "Dmitriy Shurin"
shurin@bgumail.bgu.ac.il> wrote:

I have a button field which has to update a string field in a form. The
string field updates, but the value can be seen only after i reenter the
form. it is very inconvenient, because i can't see the result
immediately. this is the code i have so far

;;;Creation of "Select" button for Vin(+)
VinPosBut=hiCreateButton(
?name 'VinPosBut
?buttonText "Select"
?callback "VinPosStr->value=objSelect()"
)
snipped
is there anything i do wrong?

Yes, you should make your callback for the button start from the
formId, rather then just the field. I'm not 100% sure as to why this
has to be, but it certainly doesn't work properly otherwise. I must
admit I've always done it this way, and rarely would have the fields
stored in global variables, so wouldn't have seen the issue you're
seeing.

Below is the modified code (I added a little to make the example
complete enough to be able to run):

;;;Creation of "Select" button for Vin(+)
VinPosBut=hiCreateButton(
?name 'VinPosBut
?buttonText "Select"
; use the form to get the field - update it that
; way
?callback "dmitriy->VinPosStr->value=objSelect()"
)

;;;Creation of Vin(+) input string field
VinPosStr=hiCreateStringField(
?name 'VinPosStr
?prompt "Vin(+)"
?editable t
)

hiCreateAppForm(
?name 'dmitriy
?formTitle "Dmitriy form"
?fields list(VinPosBut VinPosStr)
)

;;;Get a net
procedure(objSelect()
let((temp)
geDeselectAll()
geSingleSelectPoint()
temp=car(geGetSelSet())
when((temp->objType=="line")|| (temp->objType=="label")
temp=strcat("/" temp->net->name)
);end of when
geDeselectAll()
temp
);end of let
);of procedure

hiDisplayForm(dmitriy)

In other words, I created the form itself, stored in a variable
dmitriy (it should really have a sensible, prefixed, global variable
name), and then referenced the form in the callback for the button.
Doing this updates the field as soon as you've made the selection.

Best Regards,

Andrew.
 

Welcome to EDABoard.com

Sponsor

Back
Top