[comp.sys.mac.hypercard] Questions about fields

inde5py@jetson.uh.edu (02/28/91)

Hi all,

I havbe several questions regarding fields in HyperCard.  I am writing a stack
that has many one-line fields.  When the user presses the RETURN key, the
cursor disappears to the next (hidden) line of the field.  I would like the
cursor to advance to the next field instead.  I tried using a "on ReturnKey"
handler in the field script with no result.  Did I do something wrong, or am I
looking at this from the wrong angle entirely?

Also, that question brings up another one:  when tabbing from one field to the
next, I have written scripts so that the cursor goes from field to field in a
specific order (not the order in which they were created, which is ehat
HyperCard normally does).  To do this, I wrote an "On tabkey" handler that
would "click at the location of field "***"'.  This does put the cursor in the
appropriate field, but leaves the cursor in the middle of the field.  I would
like to hilite the entire field like HyperCard does when you press the tab key
and no script is written-- the cursor automatically advances to the next field
and hilightes the entry.

Also, is there a simple way of locking the text in all fields after all data is
entered?  The only thing I can think of is to "set" the parameter individually
for each field--pain!  

Lastly, is there any way of creating a horizontally-scrolling field?  I
seriously doubt it, but you guys are the ones with all the answers, so if
anyone can tall me how, I'm sure you guys can.

Thanks for the help!  Answers can be posted or E-mailed to
INDE5PY@JETSON.UH.EDU

Thanks again!

leue@galen.crd.ge.com (Bill Leue) (03/01/91)

In article <8652.27cba365@jetson.uh.edu> inde5py@jetson.uh.edu writes:
>Hi all,
>
>... (edited)
>Also, is there a simple way of locking the text in all fields after all data is
>entered?  The only thing I can think of is to "set" the parameter individually
>for each field--pain!  
>...(edited)
>Thanks for the help!  Answers can be posted or E-mailed to
>INDE5PY@JETSON.UH.EDU
>
>Thanks again!

How easy sort of depends on how you name your fields, but if, for instance,
you imposed a regular naming convention, say "fld1, fld2, ...", then
it's trivial to write a script to do it:

repeat with i = 1 to numfields
   put "fld" & i into fname
   set the LockText of card field fname to true
end repeat

I have a stack made up entirely of trivial little handlers like this
one, parameterized so that I can direct them to particular cards, number
of items, etc.  They're real handy for doing things like aligning card
objects, locking or unlocking fields, and in general, doing the kind of
repetitive grundge chores that you really don't want to do by hand.

Hope this helps,
-Bill Leue
leue@crd.ge.com

al@magimi.meta.com (Al Egan) (03/01/91)

In article <8652.27cba365@jetson.uh.edu>, inde5py@jetson.uh.edu writes:
> ... presses the RETURN key, the cursor disappears to the next (hidden) line ...
    try: on returnInField

> ... tabbing from one field to the next, field to field in a specific order...

a)  you can re-arrange the order of fields using "Bring closer" or "Send
    farther", with option or command or something the field is sent all the way.
b)  try select
c)  try drag from the left of field x + 1, the top of field x + 1 to B
        the right of field x - 1, the bottom of field x - 1
    you may need some parans around the locs
    if drag doesn't work on your version of HyperCard, use click at ...
    followed by click at ... with shiftKey

> ...Also, is there a simple way of locking the text in all fields ...
and In article <17183@crdgw1.crd.ge.com>, leue@galen.crd.ge.com (Bill Leue) writes:
> repeat with i = 1 to numfields
>    put "fld" & i into fname
>    set the LockText of card field fname to true
> end repeat

    re. the suggestion above, if you know the range of numbers of your fields,
    and they are in a few contiguous sequences:
repeat with i = 4 to 7  -- or whatever
  set the lockText of cd fld i to true
end repeat
    the number of a field is it's order on the card, initially the order
    of creation, changable via "bring closer" and "send farther".

    also re. the above suggestion, it can be shortened to:
repeat with i = 1 to 30  -- or whatever
  set the lockText of cd fld ("fld" & i) to true
end repeat
    shortening scripts is important for many executions as the shortened
    version will execute in approx. 1/2 to 2/3 the time.  Each line of hyperCard
    script becomes a "message" which must find its way from the current
    script, to the card, bg, stack, xcmds, home stack script, home xcmds,
    hyperCard xcmds, and finally to hyperCard.  Takes a while to search
    alla dat.  Also, in v 1.x, there is the interpreter time.


__
	Alan Egan				Egan Systems
	Grosse Pointe Shores	Metalogic S.a r.l.
	Michigan, U.S.A.

Jim.Russell@f421.n109.z1.fidonet.org (Jim Russell) (03/03/91)

Re single line fields:
Set the autoTab property of the fields that you want to keep as 1
liners, then return works just like tab and gets you to the next field.
 
Re field tab order:
The easiest way is to renumber the fields (using cmd-+ and cmd--),
remembering that you have to sometimes issue the command more than you
expect since there may be buttons between consecutively numbered
fields.  If you really want to script, use the select command, i.e.
select after text of field foo (to get the cursor at the end) or
select text of field foo (to get the entire field selected, which is
 
Re locking fields after data entry:
Well, if you want it to work that way for all fields, you can put an on
closeField handler in the background that does set the lockText of the
target to true, but I don't know many users (especially me) that can be
relied on to get it right the first time!
the behavior you expect of tab.)
 
About the horizontal scroll:
I think you will need an XCMD for that.


--  

        Jim Russell, Jim.Russell@f421.n109.z1.fidonet.org
      via The Black Cat's Shack's FidoNet<->Usenet Gateway
          blkcat.fidonet.org   and   Fidonet 1:109/401