[comp.sys.mac.hypercard] "Real" hypertext?

Andre_Louis_Marquis@cup.portal.com (06/28/89)

Has anyone thought about adding what, for the lack of a better phrase, I will c
"real hypertext." to Hypercard or SuperCard.  By hypertext, I mean the ability
to link a span of text in a field to a command.

In Hyper/SuperCard, you can create a text field and put transparent buttons ove
the text field so when the user click on a word, a command is executed.
Unfortunately, if the text is edited, all the buttons have to be moved.  It's a
real mess if the field can scroll.

As far as I know, it is impossible to catch all the editing events that affect 
field (character insertion, cuts, pastes, etc.) or find the bounding box of a
span of text, so hypertext can not be implemented by clever scripting.

Does anyone have any illuminating thoughts?

camber@caen.engin.umich.edu (Gregory Peters) (06/28/89)

In article <19941@cup.portal.com> Andre_Louis_Marquis@cup.portal.com writes:
>Has anyone thought about adding what, for the lack of a better phrase, I will c
>"real hypertext." to Hypercard or SuperCard.  By hypertext, I mean the ability
>to link a span of text in a field to a command.
>
>In Hyper/SuperCard, you can create a text field and put transparent buttons ove
>the text field so when the user click on a word, a command is executed.
>Unfortunately, if the text is edited, all the buttons have to be moved.  It's a
>real mess if the field can scroll.
>
>As far as I know, it is impossible to catch all the editing events that affect 
>field (character insertion, cuts, pastes, etc.) or find the bounding box of a
>span of text, so hypertext can not be implemented by clever scripting.
>
>Does anyone have any illuminating thoughts?

You can get "real" hypertext of a sort with the new "selected"
expressions.

1.  Lock the text on the field in question.

2.  Put the following in the script for the field:

on mouseUp
   lock screen
   set the locktext of me to false
   click at the clickloc
   click at the clickloc
   get the selectedtext
   set the locktext of me to true
   unlock screen

   -- Do whatever you want with the obtained text from here
   -- You may even want to pass it to the card or background
   -- if you have several fields which may reference the same
   -- word.

end mouseup

Good Luck!
             Greg Peters (camber@caen.engin.umich.edu)

pj@pnet51.cts.com (Paul Jacoby) (06/30/89)

Greg, a slightly more elegant approach to selecting the text comes from Apple
itself, in a function called 'clickline()'.  See below:

-- the following function is from the "HyperCard 1.2.2 Release Notes"
-- stack
--function clickLine returns the line of the target field
--over which the mouse was clicked.  It allows 4 pixels under the
--baseline for the psychological effect of descenders.

function clickLine
  return ((the mouseV - item 2 of the rect of the target-4)B
  div the textheight of the target) + 1
end clickLine

NOTE: That "B" up there is a line continuation character.  This works really
well in a script like:

on mouseUp
  get clickline() -- find out where they clicked
  select line it of me -- select the text
  get the selection
  
  if it is empty then
  -- do whatever
  end if
  -- and do whatever else here with the selected text
end mouseUp

This script goes in the field itself, which needs to be in a 'locked text'
state to receive the mouseUp event.  

Paul
.-----------------------------------------------------------------------------.
| UUCP: {rosevax, crash, orator}!orbit!pnet51!pj |  Working with idiots keeps |
| ARPA: crash!orbit!pnet51!pj@nosc.mil           |  my life interesting...    |
| INET: pj@pnet51.cts.com                        |                            |
`-----------------------------------------------------------------------------'

taylorj@yvax.byu.edu (07/01/89)

>Does anyone have any illuminating thoughts?

I have an illuminating rumor... :-)

We've heard many times now that "sticky buttons" (which do exactly what you
want) will be implemented in the new version of HyperCard.  I suspect that
Silicon Beach didn't try to implement them in SuperCard because they wanted to
wait and make sure they were compatible with whatever way Apple does them in
HyperCard 2.0.

Jim Taylor
Microcomputer Support for Curriculum   |
Brigham Young University               |   Bitnet: taylorj@byuvax.bitnet
101 HRCB, Provo, UT  84602             |   Internet: taylorj@yvax.byu.edu