| Author |
Message |
Dmitriy Shurin
Guest
|
Posted:
Wed Oct 06, 2004 7:16 pm Post subject:
Updating string field instantaneously |
|
|
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
|
|
| Back to top |
|
 |
Andrew Beckett
Guest
|
Posted:
Wed Oct 13, 2004 7:08 pm Post subject:
Re: Updating string field instantaneously |
|
|
On Wed, 6 Oct 2004 19:16:07 +0000 (UTC), "Dmitriy Shurin"
<shurin@bgumail.bgu.ac.il> wrote:
| Quote: | 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. |
|
| Back to top |
|
 |
Diva Physical Verificatio
Guest
|
Posted:
Wed Oct 13, 2004 7:59 pm Post subject:
Re: Updating string field instantaneously |
|
|
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:
| Quote: | 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. |
|
|
| Back to top |
|
 |
Pete nospam Zakel
Guest
|
Posted:
Wed Oct 13, 2004 8:30 pm Post subject:
Re: Updating string field instantaneously |
|
|
In article <df2qm05vlte1mph7tmh4rf0r9mndl2b8ve@4ax.com> Andrew Beckett <andrewb@DcEaLdEeTnEcTe.HcIoSm> writes:
| Quote: | 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.
|
Andrew is correct, and the reason is because the initial field is a defstruct.
When it is instantiated into a form, a user type is created from the
defstruct. That user type does not replace the defstruct, which is still
the value of the field symbol, but becomes a property of the form where the
field symbol is the property name.
So field->value will refer to the value of the defstruct (which will work for
uninstantiated fields) and form->field->value will refer to the value of the
user type (which is the only way to reference instantiated fields).
-Pete Zakel
(phz@seeheader.nospam)
"What makes the universe so hard to comprehend is that there's nothing
to compare it with." |
|
| Back to top |
|
 |
|
|
|
|