[comp.sys.mac.hypercard] returning line numbers from fields

knox@umd5.umd.edu (Garry Knox) (12/02/88)

 Help. How can you get a line number returned when you click on a field?




 ------------------------------------------------------------------------
 Garry Knox
 Computer Science Center
 University of Maryland, College Park
 Home of nobody really important.

baum@Apple.COM (Allen J. Baum) (12/02/88)

[]
>In article <4296@umd5.umd.edu> knox@umd5.umd.edu (Garry Knox) writes:
>
> Help. How can you get a line number returned when you click on a field?
>

Boy oh boy, would I like a good answer to this one.
The ways that I've tried are:

1. start with locktext of the field set
   then, in the script of the field:

on mouseup
set the locktext of me to false --make sure click isn't intercepted
click at the clickloc 
set the locktext of me to true
return word 2 of the selectedLine
end mouseup

This is very slow- locking and unlocking the field seems to be the
culprit, but I'm not sure. This script gives virtual line numbers, i.e.
wrapped lines count as a single line.

1A. Like the above, but cover the field with a button. Locktext of the
    field should be false. Instead of locking/unlocking the field, hide/show
    the button.

Also slow- hiding/showing the button may be the culprit

2. start with locktext of the field set, or with a button covering the field.
   Then, in the script of the field or button:

on mouseup
 return (the clicky - the top of me + the scroll of me)/the textheight of me
end mouseup

Much faster, but wrapped lines are counted as two lines


What I'd really like to do is have a scrolling field I can treat just like
the fields in the font/da mover, i.e. clicking on a line in the field 
highlights the line, draging highlights more, and shift-click extends the
selection. Both line number, and number of lines should be returned, I can
do this with script 1. above, " selecting the selectedtext" and returning 
"the number of lines of the selectedtext", but its horribly slow for such
a simple function (several seconds).

Anyone have any better ideas?

--
		  baum@apple.com		(408)974-3385
{decwrl,hplabs}!amdahl!apple!baum

englandr@phoenix.Princeton.EDU (Scott Englander) (12/04/88)

In article <21506@apple.Apple.COM> baum@apple.UUCP (Allen Baum) writes:
>What I'd really like to do is have a scrolling field I can treat just like
>the fields in the font/da mover, i.e. clicking on a line in the field 
>highlights the line, draging highlights more, and shift-click extends the
>selection. Both line number, and number of lines should be returned

There is such a thing.  It's an XCMD called DoList, by James Paul, which
is included in the stack Developer Stack 1.2, which has all sorts of
other neat goodies.
-- 

                                               - Scott