where I put my scripts

Rob Cozens rcozens at pon.net
Fri May 3 19:26:13 EDT 2002


>Uh.  I don't understand what lowest means?  Do you mean libraries 
>before buttons?

If I may reply for David, he means lowest in the message passing hierarchy.

An event, eg: clicking the mouse, sends a mouseUp message up the 
message hierarchy.  MouseUp is sent first to the control under the 
mouse (or the card if the click is outside all controls).  If there 
is no mouseUp handler in the control's script, mouseUp is passed to 
the card.  If there is no mouseUp handler in the card's script, 
mouseUp is passed to (I believe) the group, then the stack, then each 
stack in use, and finally to the MetaCard engine.

Each message passes up the chain until it finds an object with the 
appropriate handler.  That handler can terminate the message, or pass 
it or a new message on up the message chain after it's done whatever 
else it's doing; so one message can trigger handlers in multiple 
objects:

on terminateMessage
   doWhatever
end terminateMessage

on passMessage
   doWhatever
   pass passMessage
end passMessage

on changeMessage
   doWhatever
   send anotherMessage
end changeMessage

In other words, and I'm probably paraphrasing Sarah & Steve, if you 
have a handler that is specific to a control, put it in the control's 
script.  If you have a handler that is general to multiple controls 
on one, and only one, card, put a single copy of it in the card's 
script instead of putting a copy in each control.  If it's general to 
a stack, put it in the stack script.  If it is shared by multiple 
stacks in the same application, put it in the mainstack script or a 
library stack.  If it is used by multiple stacks in multiple 
applications, put it in a library stack.
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list