[comp.sys.mac.hypercard] Getting part of a field

urban@sol.UUCP (10/29/87)

I am presenting a (locked) text field to the user.  When the user
clicks in the field, I want to be able to find out which ordinal word
in the field he has clicked (the first?  the tenth?).  I am trying to
do it by saying

	(stuff to turn off TextLock)
		drag from the ClickLoc to 0,0
and looking at the number of words in the selection.

Unfortunately, this "drag" command doesn't seem to have any effect,
nor can I seem to come up with one that has.

Am I going about this all wrong?

		
-- 
   Mike Urban
	...!trwrb!trwspp!spp2!urban 

"You're in a maze of twisty UUCP connections, all alike"

andyi@mmm.UUCP (10/30/87)

I too couldn't seem to get the drag to work within fields.  Outside it's fine, 
but inside no dice.  (Anybody have some RAID?)  What did work for me to 
select text in a field is by clicking at one end of the chosen text and 
shift-clicking at the other end.  Hmmm. That's "click at <location>" followed
by "click at <location2> with shift".  

This worked but there are other horrors doing this as well.  With text 
selected this way, the user has the ability to change the text in the field 
even if it's locked. Just try typing on the keyboard.

Hope it helps.

Andy Ihlenfeldt                                   uucp: ihnp4!mmm!andyi
3M, St. Paul, MN                                  phone: (612) 736-7143

mike@ronin.UUCP (11/02/87)

What we really need is a list object type so we can put stuff in the list
and allow the user to select items in the list without being able to change
the text of the list.  But we don't.

To solve this problem for in my own stacks, I set up a scrolling field with
locked text.  Next to each line in the field, I put a little arrow button.  If
the user clicks on the field, nothing will happen.  But if the user clicks
on the arrow, the script of the button will compute the line of the field
that this arrow is pointing to based on "the scroll of field such-and-such"
and then extract that line from the field.  If anyone is interested, I can
put up the script of the button that does this.

Michael Nowak

"My opinions are my own and not necessarily the opinions of my employer."

nazgul@apollo.uucp (Kee Hinckley) (11/03/87)

In article <370@tardis.cc.umich.edu> mike@ronin.cc.umich.edu (Michael Nowak) writes:
> What we really need is a list object type so we can put stuff in the list
> and allow the user to select items in the list without being able to change
> the text of the list.  But we don't.
> 

Wait.  Do you want to let a person point to a rendered line (as opposed to
the virtual line, which is terminated by a carriage return) and select it?
I have a script that will do that if anyone is interested.  And if you assume
that the rendered line is unique in the field it's fairly easy to find the
virtual line as well.

                                                -nazgul
-- 
### {mit-erl,yale,uw-beaver}!apollo!nazgul  ### apollo!nazgul@eddie.mit.edu ###
### pro-angmar!nazgul@pro-sol.cts.com       ### nazgul@apollo.com           ###
###   (617) 641-3722  300/1200/2400         ###                             ###
I'm not sure which upsets me more; that people are so unwilling to accept       responsibility for their own actions, or that they are so eager to regulate     everyone else's.

chips@tekchips.TEK.COM (Chip Schnarel) (11/04/87)

In article <370@tardis.cc.umich.edu>, mike@ronin.cc.umich.edu (Michael Nowak) writes:
> What we really need is a list object type so we can put stuff in the list
> and allow the user to select items in the list without being able to change
> the text of the list.  But we don't.
> 
> To solve this problem for in my own stacks, I set up a scrolling field with
> locked text.  Next to each line in the field, I put a little arrow button.
> 
> Michael Nowak
    
    I have built a similar interface covering each line in the scroll list
    with a button.  This looks and acts similar to, but not exactly the
    same as, a "List Manager" scroll list.  Also it is my understanding that
    the inclusion of scroll lists or selection lists will be in some future
    release of Hypercard.  In the mean time, would it be possible to program
    an XCMD to provide this functionality?

    Chip Schnarel
    Tektronix, Inc.
    chips%tektronix.csnet@csnet-relay.arpa
    ...!tektronix!tekchips!chips

mike@ronin.cc.umich.edu (Michael Nowak) (11/04/87)

It turns out that Brian McGhie provided a function in Windoid #3 that
returns the field line number of scrolling locked field that a user
clicked in...

Function ClickLine
	return (trunc(((scroll of the target)
	+ (item two of the clickloc)
	- (item two of the rect of the target))
	div the textheight of the target) + one)
End ClickLine

Thank you very much to Mr. McGhie and Mr. Leffler, editor of Windoid!

Michael Nowak

mike@ronin.cc.umich.edu (Michael Nowak) (11/04/87)

 I got the script from Brian McGhie (listed in Windoid #3) which does this.
 Silly me for thinking we couldn't just script this feature in!  :)  But,
 if you want to send me your version, I'd be happy to see it.

 Michael Nowak
 mike@ronin.cc.umich.edu
 mike!ronin!tardis!umix!uunet!seismo
 ~

ns@CAT.CMU.EDU (Nicholas Spies) (11/05/87)

They way to avoid having the user bash the selected text is to save the
selection into a local variable and then click elsewhere to remove the
selection while still in the handler. Such as:

on mouseUp -- for any field named "xx", put into background or stack script
  if the name of the target contains "xx" then
     set lockText of the target to false
     repeat two times
       click at the clickLoc -- the last place clicked
      end repeat
     put the selection into found
     click at 1,1 -- to remove selection so user can't type over it
     set lockText of the target to false
     if found is not empty then
       put found -- or whatever else you want to do with word selected
     end if
  end if
end mouseUp

Often by remembering how you can do it by hand is (at least for now) the
way to program it in Hypertalk.

--Nick