Advice on Messaging System
Ken Ray
kray at sonsothunder.com
Tue Dec 13 13:35:17 EST 2005
> Does anyone know of a better way to do this? Any ideas or suggestions
> greatly appreciated.
Personally David, I'm thinking you're doing way too much work. ;-)
I'd switch it from a "listening" model to "notification" model. What I'd do
is create a custom property (like "uMessages") for each control that
contains a list of things they care about. Then create a single handler
called "NotifyControls" (or the equivalent) that does this:
on NotifyControls pMessage,pMessageParam
repeat with x = 1 to the number of controls
if pMessage is among the lines of (the uMessages of control x) then
send pMessage && pMessageParam to control x
end if
end repeat
end NotifyControls
So when your control that switches languages, it does:
NotifyControls "SetLanguage","Italian"
which would send the "SetLanguage" command to each control that cared. You
could then put code in the control to handle this, or let the message move
up to the card and then handle it there, or both. Personally I like the
"card handles it all and there's no code in the controls" approach, but
that's me.
HTH,
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list