[comp.sys.mac.hypercard] odd-shaped buttons

ch2i+@andrew.cmu.edu (Charles A. Hill) (10/04/90)

I want to use the outlines of a picture to define the parameters of a
button.  In other words, if someone clicks anywhere within the outlines
of a picture (no matter what shape the picture is), the button will be
activated.  I've been trying to improvise by filling all the nooks and
crannies of the pictures with tiny buttons, but, needless to say, this
is not an acceptable solution.

I don't know any languages but Hypertalk, but I'm told that making an
irregularly shaped picture "hot" is no sweat in a language such as C. 
Are there any Xcmd's that I could plug into Hypercard to do what I want
to do?  (I'm also told that Supercard is capable of doing this, but that
HC 2.0 will not have this capability.  Sure would be a nice addition, as
long as we're already taking suggestions, for v2.1.)

Any suggestions would be greatly appreciated.

Charlie Hill
Literacy in Science Research Center
Carnegie Mellon University

francis@daisy.uchicago.edu (Francis Stracke) (10/13/90)

In article <Qb2YKgy00Uh_I2T2V2@andrew.cmu.edu> ch2i+@andrew.cmu.edu (Charles A. Hill) writes:
>I want to use the outlines of a picture to define the parameters of a
>button.  In other words, if someone clicks anywhere within the outlines
>of a picture (no matter what shape the picture is), the button will be
>activated.  I've been trying to improvise by filling all the nooks and
[...]
>I don't know any languages but Hypertalk, but I'm told that making an
>irregularly shaped picture "hot" is no sweat in a language such as C. 

It's not incredibly easy.  You'd have to have some way of getting the
region from the bitmap (is this supported by the Toolbox?), then check,
for each click, if the mouse is inside the region.

In HC, this would take a XFCN returning a handle to the region, and
another to check if a given point is in a given region.  The card script
would catch the mouseUp event, then act on it as necessary.

Anybody in comp.sys.mac.programmer got any better ideas?

| Francis Stracke		| My opinions are my own.  I don't steal them.|
| Department of Mathematics	|=============================================|
| University of Chicago		| A mathematician is a professional	      |
| francis@zaphod.uchicago.edu	|   schizophrenic.--Me.		       	      |

linde@embezzle.stanford.edu (Andrei Linde) (10/13/90)

francis@daisy.uchicago.edu (Francis Stracke) writes:

>In article <Qb2YKgy00Uh_I2T2V2@andrew.cmu.edu> ch2i+@andrew.cmu.edu (Charles A. Hill) writes:
>>I want to use the outlines of a picture to define the parameters of a
>>button.  In other words, if someone clicks anywhere within the outlines
>>of a picture (no matter what shape the picture is), the button will be
>>activated.  I've been trying to improvise by filling all the nooks and
>[...]
>>I don't know any languages but Hypertalk, but I'm told that making an
>>irregularly shaped picture "hot" is no sweat in a language such as C. 

>It's not incredibly easy.  You'd have to have some way of getting the
>region from the bitmap (is this supported by the Toolbox?), then check,
>for each click, if the mouse is inside the region.

>In HC, this would take a XFCN returning a handle to the region, and
>another to check if a given point is in a given region.  The card script
>would catch the mouseUp event, then act on it as necessary.

>Anybody in comp.sys.mac.programmer got any better ideas?

>| Francis Stracke		| My opinions are my own.  I don't steal them.|
>| Department of Mathematics	|=============================================|
>| University of Chicago		| A mathematician is a professional	      |
>| francis@zaphod.uchicago.edu	|   schizophrenic.--Me.		       	      |
If picture is not too complex then just make several buttons on it which
would countain script:
on mouseUp
	click at loc of card button "MyPicture"
end mouseUp
    
and call one of the buttons on this picture "MyPicture" and give it a
script that you want to be executed.

Again if the picture is not too complex you will beable to aproximate it
with rectangular buttons preety well. 

This is not the only choice, so if you don't like it try something else.

          - Dmitri Linde

aslakson@cs.umn.edu (Brian Aslakson) (10/15/90)

linde@embezzle.stanford.edu (Andrei Linde) quotes every damn word that:
>francis@daisy.uchicago.edu (Francis Stracke) writes:
and which I mostly delete.
>>In article <Qb2YKgy00Uh_I2T2V2@andrew.cmu.edu> ch2i+@andrew.cmu.edu (Charles A. Hill) writes:
>>>I want to use the outlines of a picture to define the parameters of a
>>>button.  In other words, if someone clicks anywhere within the outlines
>>>of a picture (no matter what shape the picture is), the button will be
>>>activated.  I've been trying to improvise by filling all the nooks and
>>Anybody in comp.sys.mac.programmer got any better ideas?

Why yes.  Not me though.  A certain Apple gentleman very recently posted
that he had and would send to requesters a stack he wrote that does just
that.  His name and address is:  Greg L. Anderson, greggor@apple.com.  I
will forward what I received from Greg to ch2i+@andrew.cmu.edu but other
people should request from Greg, please not from me!!  Please notice how
well adjusted this paragraph is.

Oh, the stack's name?  Ah, ask him for his polybutton stack.

-- 
Brian Aslakson

aslakson@cs.umn.edu
mac-admin@cs.umn.edu  <-= Macintosh related

np@doc.ic.ac.uk (Nigel Perry) (10/16/90)

Outline of problem (I can't include the previous article):

Needed a button the shape of an arbitrary picture.

Ok, I have written a WDEF which displays a PICT (B/W only), it either
masks the given PICT or takes another to act as the mask, it then
constructs an arbitrary shaped window (complete with holes, non-contiguous
areas etc.). I've been waiting for HC 2.0 before writing some XCMDs to
interface to this WDEF. With these XCMDs you'll be able to construct
arbitrary shaped buttons. I've just got HC 2.0, now all I need is the
time to finish the project... I'll post to sumex when(if) its finished.

---
Nigel Perry                                  Department of Computing
                                             Imperial College
Janet: np@uk.ac.ic.doc                       London
ARPA:  np%uk.ac.ic.doc@ucl-cs                SW7
Uucp:  np@icdoc.UUCP, ukc!icdoc!np           England

bkuo@aludra.usc.edu (Benjamin Kuo) (10/17/90)

Exactly. I've done it with my own (bomb-prone) XFCN, but basically what I did
was write an XFCN which took the locations of a mouseDown on the card,
check the coordinates (in form x,y) with a region (x1,y1,x2,y2,x3,y3,etc)
and returned a "1" if it was in the region, and a "0" if it wasn't. I used
another XCMD to hilight that region.  There's a lot of overhead involved,
though, if you have more than two or three regions to check (card scripting
from hell....) I assume you could do it via scripts, but that's SLOW...

(Of course, I haven't even seen HC2.0 yet, so I can't make any guarantees
that there isn't something already there to do this...)

Benjamin Kuo
bkuo@usc.edu

carsup@extro.ucc.su.OZ.AU (Fisher Library support) (10/17/90)

In article <1990Oct13.000500.14994@midway.uchicago.edu> francis@daisy.uchicago.edu (Francis Stracke) writes:
>In article <Qb2YKgy00Uh_I2T2V2@andrew.cmu.edu> ch2i+@andrew.cmu.edu (Charles A. Hill) writes:
>>I want to use the outlines of a picture to define the parameters of a
>>button.  In other words, if someone clicks anywhere within the outlines
>>of a picture (no matter what shape the picture is), the button will be
>>activated.  I've been trying to improvise by filling all the nooks and
>[...]
>>I don't know any languages but Hypertalk, but I'm told that making an
>>irregularly shaped picture "hot" is no sweat in a language such as C. 
>
>It's not incredibly easy.  You'd have to have some way of getting the
>region from the bitmap (is this supported by the Toolbox?), then check,
>for each click, if the mouse is inside the region.
>
>In HC, this would take a XFCN returning a handle to the region, and
>another to check if a given point is in a given region.  The card script
>would catch the mouseUp event, then act on it as necessary.

Can't you use two buttons such that a smaller one resides within the bigger
to map out the insides so effectively the button is the "boundary"?
There is something called PolyButtons from Heizer Software.  I got mine with
the Waite Groups HyperCard Book.  I don't have the name off hand but it's the
one with a wizard on the cover that looks remarkably like Waite!  The stack
offered in the book directed me to purchase it from Heizer.  Check it out.
PolyButtons allows you to have buttons of any shape and size within reason.

**My employers don't understand me, so I guess I'm on my own when I speak out**
Norton Chia		|	I *think* my address is 
Micro Support		|		carsup@extro.ucc.su.OZ.AU
*******************************************************************************

kulp@cs.nps.navy.mil (Jeff Kulp x2174) (10/17/90)

In article <1990Oct17.004859.27634@metro.ucc.su.OZ.AU> carsup@extro.ucc.su.OZ.AU (Fisher Library support) writes:
>There is something called PolyButtons from Heizer Software.  I got mine with
>the Waite Groups HyperCard Book.  I don't have the name off hand but it's the
>one with a wizard on the cover that looks remarkably like Waite!  The stack
>offered in the book directed me to purchase it from Heizer.  Check it out.
>PolyButtons allows you to have buttons of any shape and size within reason.

The name of the book is "The Waite Group's Hypertalk Bible."

Jeff Kulp
kulp@cs.nps.navy.mil

greggor@Apple.COM (Greg L. Anderson) (10/18/90)

In article <2364@gould.doc.ic.ac.uk> np@doc.ic.ac.uk (Nigel Perry) writes:
>Needed a button the shape of an arbitrary picture.
>
>Ok, I have written a WDEF which displays a PICT (B/W only), it either
>masks the given PICT or takes another to act as the mask, it then
>constructs an arbitrary shaped window (complete with holes, non-contiguous
>areas etc.).

My polybutton XFCNs (which work with HyperCard 2) use regions to identify
button shapes.  At the moment, said regions can only be defined as
polygons.  If you had a PICT->Region conversion routine, you could probably
merge your code with mine & end up with a pretty nifty irregular-button
XFCN.


  ___\    /___       Greg Anderson (6 kyu)      ___\    /___   . O . "Pon Nuki
  \   \  /   /     Advanced Technology Group    \   \  /   /   O . O  is ideal
   \  /\/\  /        Apple Computer,  Inc.       \  /\/\  /    . O .  shape."
    \/    \/           greggor@apple.com          \/    \/ 
-- 
  ___\    /___       Greg Anderson (6 kyu)      ___\    /___   . O . "Pon Nuki
  \   \  /   /     Advanced Technology Group    \   \  /   /   O . O  is ideal
   \  /\/\  /        Apple Computer,  Inc.       \  /\/\  /    . O .  shape."
    \/    \/           greggor@apple.com          \/    \/ 

greggor@Apple.COM (Greg L. Anderson) (10/18/90)

In article <1990Oct17.004859.27634@metro.ucc.su.OZ.AU> carsup@extro.ucc.su.OZ.AU (Fisher Library support) writes:
>There is something called PolyButtons from Heizer Software.  I got mine with
>the Waite Groups HyperCard Book.

I don't recommend this version of polybuttons.  (1) it's in
HyperTalk, & therefore too slow to be useful, (2) the editor is not
very good, and (3) it's not free.

DISCLAIMER:	I wrote a competing routine that does the same thing, but
		(1) It's an XFCN, (2) it has a nice editor, and (3) it's
		free.  Mail me if you want a copy.


>>In article <Qb2YKgy00Uh_I2T2V2@andrew.cmu.edu> ch2i+@andrew.cmu.edu (Charles A. Hill) writes:
>>In HC, this would take a XFCN returning a handle to the region, and
>>another to check if a given point is in a given region.  The card script
>>would catch the mouseUp event, then act on it as necessary.

I missed this the first time it came by.  Polybuttons does just that.
(You still need Pict->region, which I suppose is a bit complicated;
turn the Pict into a bitmap, then call BitmapToRegion.)

-- 
  ___\    /___       Greg Anderson (6 kyu)      ___\    /___   . O . "Pon Nuki
  \   \  /   /     Advanced Technology Group    \   \  /   /   O . O  is ideal
   \  /\/\  /        Apple Computer,  Inc.       \  /\/\  /    . O .  shape."
    \/    \/           greggor@apple.com          \/    \/ 

hpoppe@ncar.ucar.edu (Herb Poppe) (10/18/90)

Just a point of information on this thread. Keith Rollin, at Apple,  
created a stack called "Region Buttons" back in 1987. The stack introduced 
(with examples and discussion) an XCMD that implemented buttons as 
regions. Source code was included.

Herb Poppe             hpoppe@ncar.ucar.edu
NCAR                      (303) 497-1296
1850 Table Mesa Dr.
Boulder, CO  80307-3000

geoff@pmafire.UUCP (Geoff Allen) (10/20/90)

linde@embezzle.stanford.edu (Andrei Linde) writes:
>If picture is not too complex then just make several buttons on it which
>would countain script:
>on mouseUp
>	click at loc of card button "MyPicture"
>end mouseUp
>    
>and call one of the buttons on this picture "MyPicture" and give it a
>script that you want to be executed.

Another alternative: put in each of your buttons...

on mouseUp
	doWhatIWant
end mouseUp

and in your card, background, or stack script...

on doWhatIWant
	-- Whatever you want to do when the user clicks in the irregular
	-- area 
end doWhatIWant


-- 
Geoff Allen         \  Computers are useless.  
uunet!pmafire!geoff  \  They can only give you answers.
bigtex!pmafire!geoff  \		-- Pablo Picasso