[comp.sys.mac] Button hilighting in HyperTalk

kdmoen@watcgl.UUCP (09/13/87)

I'm working on a HyperCard database intended to be used by people with
no knowledge of computers or Macintoshes.  I've found that causing
buttons to highlight when the cursor moves over them makes the user
interface much more intuitive.

This turns out to be easy to do in HyperTalk.  You simply include the
following code in each button script:
	on mouseEnter
		set hilite of the target to true
	end mouseEnter

	on mouseLeave
		set hilite of the target to false
	end mouseEnter

Here's my problem.  I prefer not to edit the script of every single
button in my database to add this code.  I have tried putting the code
into the stack script, where it will be inherited by every button in
the stack.  This works, but unfortunately, it also gets inherited by fields,
which is not what I want.  Any suggestions?
-- 
Doug Moen
University of Waterloo Computer Graphics Lab
UUCP:     {ihnp4,watmath}!watcgl!kdmoen
INTERNET: kdmoen@cgl.waterloo.edu

psych@watdcsu.UUCP (09/15/87)

Use the following message handler to only hilite buttons
 
on mouseenter
 if "button" is in the target then set hilite of the target to true
end mouseenter
 
on mouseleave
 if "button" is in the target then set hilite of the target to false
end mouseleave

 
Richard Crispin
Dept. of Psychology
University of Waterloo
Waterloo, Ont.
Canada    N2L 3G1
(519)885-1211 ext 2879

keith@apple.UUCP (Keith Rollin) (09/15/87)

In article <1748@watcgl.waterloo.edu> kdmoen@watcgl.UUCP (Doug Moen) writes:
>I'm working on a HyperCard database intended to be used by people with
>no knowledge of computers or Macintoshes.  I've found that causing
>buttons to highlight when the cursor moves over them makes the user
>interface much more intuitive.
>
>This turns out to be easy to do in HyperTalk.  You simply include the
>following code in each button script:
>	on mouseEnter
>		set hilite of the target to true
>	end mouseEnter
>
>	on mouseLeave
>		set hilite of the target to false
>	end mouseEnter
>
>Here's my problem.  I prefer not to edit the script of every single
>button in my database to add this code.  I have tried putting the code
>into the stack script, where it will be inherited by every button in
>the stack.  This works, but unfortunately, it also gets inherited by fields,
>which is not what I want.  Any suggestions?

The function "target" returns a string that can be used to identify what object
is getting the system message. In the case of a button getting hit, "the target"
would contain something like "card button id <number>" or "bkgrnd button id
<number>". Check this string for the work button, and you're set.

on mouseEnter
     if the second word of the target is "button" then
         set hilite of the target to true
     end if
end mouseEnter


-- 

Keith Rollin
Sales Technical Support
Apple Computer

Disclaimer: I read this board as a genuinely concerned Mac-Head. Any views
            expressed are my own until my boss finds out what I'm doing.
            However, that doesn't mean I can't recognize a good idea and
            do something about it...

winkler@apple.UUCP (Dan Winkler) (09/15/87)

You can put a mouseEnter hiliter in your stack script and only have it
respond to buttons like this:

  on mouseEnter
    if "button" is not in the target then pass mouseEnter
    set the hilite of the target to true
  end mouseEnter

beloin@batcomputer.tn.cornell.edu (Ron Beloin) (09/15/87)

In article <1748@watcgl.waterloo.edu> kdmoen@watcgl.UUCP (Doug Moen) writes:

>Here's my problem.  I prefer not to edit the script of every single
>button in my database to add this code.  I have tried putting the code
>into the stack script, where it will be inherited by every button in
>the stack.  This works, but unfortunately, it also gets inherited by fields,
>which is not what I want.  Any suggestions?

You can write a script that will poke the script you want into the buttons.
Put the desired script into a field. Then use 
  get the script of button i
  put newscript after it -- newscript contains the additional code
  set script of button i to it
with the appropriate loops to get you through cards and buttons
You can also be more selective with
  if the name of button i contains the chars "whatever" then set script ...
so you can decide if the button will have the property when you name it.

I haven't tried this, but I think it will work.
--ron.
 Ron Beloin, Ecosystems Research Center, Corson Hall, Cornell, Ithaca,NY 14853
 >> opinions << BITNET:BELOIN@CRNLTHRY; INTERNET:beloin@tcgould.tn.cornell.edu
 >> are mine << UUCP:{cmcl2,shasta,uw-beaver,rochester}!cornell!tcgould!beloin