graphic radio buttons
Cubist at aol.com
Cubist at aol.com
Sun Feb 10 14:45:01 EST 2002
I've been following the thread about how to handle graphical hiliting for
an unGodly number of objects, and let me add my voice to the chorus of those
who are wondering what the heck kind of purpose *requires* messing around
with a *five-digit* number of whatever-they-ares.
However, presuming that there really is a valid reason to play with *more
than 30,000* of *anything*, I have a HyperCard stack that exploits a
technique which should prove useful. Go to this URL --
http://members.aol.com/cubist/Download.html
-- and download the DieRoller stack. This stack uses a
graphic-hilite-on-mouseEnter effect on a 7x10 array of buttons, and it works
by exploiting the crap out of HC's message-passing hierarchy. I'll explain
the trick here, but you should play with the stack to see it in action...
Every one of the 70 buttons in that 7x10 array has a unique name. *None*
of them contains *any* handlers -- whenever a message is sent to any of these
buttons, that message just "falls thru" to the card, i.e. to the next plateau
in the message-passing hierarchy. The card script contains all the code which
makes the hiliting work.
on mouseEnter
put the target into Fred
-- "the target" is an HC function that tells you whichever object
-- the message (mouseEnter, in this case) was originally sent to
if word 1 of the short name of the target "DieRoll" then exit mouseEnter
-- "the target" would give you something like "card button 'Fred'";
-- "the short name of the target" returns just the "Fred" part of it.
-- each of the 70 array-buttons is named "DieRoll something", and
-- no other buttons/fields/etc are. thus, this statement allows this handler
-- to ignore everything that's not a "DieRoll whatever" button.
global LastBtn
-- global variables should be clear, yes?
put the short name of Fred into ThisBtn
set the icon of Fred to "marked"
-- this line is what actually does the graphical hilite on whichever
-- button the pointer just entered
if there is a cd btn LastBtn and (ThisBtn LastBtn) then set the icon of
cd btn LastBtn to "clear"
-- clearing the hilite of the last button.
--this is where that LastBtn global variable comes into play...
put ThisBtn into LastBtn
-- ...and here's where it gets defined! this is why the line just previous
has
-- that "if there is a cd btn LastBtn" clause; when this stack first opens,
-- LastBtn is undefined, and setting the icon of an undefined button is an
HC no-no
end mouseEnter
on mouseLeave
if word 1 of the short name of the target "DieRoll" then exit mouseLeave
-- see above for comment on "the short name of the target"
global LastBtn
set the icon of cd btn LastBtn to "clear"
end mouseLeave
I think it should be relatively easy to implement the underlying concept
in Rev/MetaCard, yes?
Hope this helps...
More information about the use-livecode
mailing list