Can An Object Know About Itself?

Mike Bonner bonnmike at gmail.com
Fri Mar 2 08:17:18 EST 2012


Another thought, use a frontscript.

As a test I created a group with several objects including 1 button to use
as frontscript.

For the group, this:

on selectedobjectchanged
   if the long id of button "fscriptb" of me is not among the lines of the
frontscripts then
      insert script of button "fScriptb" of me into front
   end if
end selectedobjectchanged

command rossiObjectDeselected
   put the long id of me & random(1000)
end rossiObjectDeselected



For the button this:

on selectedobjectchanged pVar
   set the oldSelected of this stack  to the nowSelected of this stack
   set the nowselected of this stack to the selectedobjects
   put the oldselected of this stack
   if the oldselected of this stack is not empty then dispatch
"rossiObjectDeselected" to (the oldselected of this stack)
   pass selectedobjectchanged
end selectedobjectchanged


It seems to work ok, though it doesn't take into account multiple instances
of the group, so perhaps another property to determine if the script has
been inserted into front already or not.  Then use that property rather
than the contents of the frontscripts to decide whether or not to insert
the script into front.


On Fri, Mar 2, 2012 at 5:59 AM, Mark Schonewille <
m.schonewille at economy-x-talk.com> wrote:

> Hi,
>
> Make the group a background. That should allow it to catch the
> selectedObjectChanged message.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
> KvK: 50277553
>
> Download the Installer Maker Plugin 1.7 for LiveCode here
> http://qery.us/za
>
> On 2 mrt 2012, at 07:48, Scott Rossi wrote:
>
> > Is there any way for an object to know when it is unselected using only
> > scripts within the object itself?
> >
> > The selectedObjectChanged is sent to an object when it is selected, but
> when
> > the object is deselected, the object will only get the
> selectedObjectChanged
> > message if the selection is changed to nothing.  Is there some way for
> the
> > object to know it is no longer selected without resorting to an external
> > script? (no front, back, card or stack).
> >
> > I have a group of objects that needs to reorganize itself when it is
> > deselected, but I'd like to avoid using external scripts to do this so
> the
> > object is easily portable.
> >
> > Thanks for any suggestions.
> >
> > Regards,
> >
> > Scott Rossi
> > Creative Director
> > Tactile Media, UX Design
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list