setProp Clarification

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

setProp Clarification

Post by CenturyMan1979 » Tue Apr 16, 2013 2:55 am

Hey All,

Here is the code in my custom group

Code: Select all

setProp cSelected pValue
   put pValue = true into sSelected
   set the visible of graphic "_bg" of me to sSelected
end cSelected
I can call the setProp within the group by using this,

Code: Select all

set the cSelected of me to true
Now the question I have is it possible to call this method from the card script. I tried this because it seems like it should work but it does not,

Code: Select all

set the cSelected of group id 1234 to false

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: setProp Clarification

Post by dunbarx » Tue Apr 16, 2013 3:32 am

Sure. Make a button. In the button script:

Code: Select all

on mouseUp
   set the yourProp of me to random(99)
end mouseUp
And in the card script:

Code: Select all

 setprop yourProp newVal
   answer newVal
end xxx
SetProp passes through the message hierarchy just like any message.

Craig Newman

CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

Re: setProp Clarification

Post by CenturyMan1979 » Tue Apr 16, 2013 3:53 am

dunbarx wrote:Sure. Make a button. In the button script:

Code: Select all

on mouseUp
   set the yourProp of me to random(99)
end mouseUp
And in the card script:

Code: Select all

 setprop yourProp newVal
   answer newVal
end xxx
SetProp passes through the message hierarchy just like any message.

Craig Newman
I am trying to do the opposite. I would want the setProp in the button and want to set it from the card script.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: setProp Clarification

Post by dunbarx » Tue Apr 16, 2013 4:11 am

Ah.

Well, if you switch the scripts, so in the card script you have:

Code: Select all

on mouseUp
   set the yourProp of btn "b1" to random(99)
end mouseUp
And in the button (named "b1") script:

Code: Select all

setprop yourProp newVal
   answer newVal
end yourProp
Since the property you are setting is directed to the button, it will trigger a setProp control structure and be trapped by the handler in that button. In a sense, you might think of it as "sending" the setProp trigger to the button by setting the property of that button, down the message path (from card down to button) instead of up.

Craig Newman

Post Reply