HyperCard: Script to Check for Clicked Object (7/92)

This function takes a point and tells you which object is at that location.
If you pass it the point returned by the clickLoc function, you can tell
which object the user clicked on.

function hitTest point
repeat with i = 1 to the number of card buttons
if point is within rect of card button i
then return "card button id " & short id of card button i
end repeat
repeat with i = 1 to the number of card fields
if point is within rect of card field i
then return "card field id " & short id of card field i
end repeat
repeat with i = 1 to the number of bkgnd buttons
if point is within rect of bkgnd button i
then return "bkgnd button id " & short id of bkgnd button i
end repeat
repeat with i = 1 to the number of bkgnd fields
if point is within rect of bkgnd field i
then return "bkgnd field id " & short id of bkgnd field i
end repeat
if globalPoint(point) is within rect of card window
then return "card id " & short id of this card
return empty -- no such object
end hitTest


This article is adapted from the Claris Tech Info database.
Published Date: Feb 19, 2012