Page 1 of 1

Alert when custom properties value changed

Posted: Fri Jun 24, 2016 11:53 am
by shalu
HI All,

I have n number of cards in my stack and each of the card having custom properties eg: x_value, y_value, focus_val these are same in all cards but the corresponding values might different, the defalt value is 0 when ever the values of x_value, y_value, focus_val changed, I want an alert message like "answer x_value, y_value, focus_val changed" please help me :oops:

Re: Alert when custom properties value changed

Posted: Fri Jun 24, 2016 12:31 pm
by Klaus
Hi Shalu,

put some SETPROP handlers, one for each property you want to "monitor", into your stack script like this:

Code: Select all

setprop x_value tValue

   ## To prevent recursion!
   lock messages
   set the x_value of the target to tValue
   unlock messages
   answer "The property x_value has been modified for" && the target
end x_value
The you will see this dialog everytime your scripts change this custom property of any card!
Tested and works! :D


Best

Klaus

Re: Alert when custom properties value changed

Posted: Fri Jun 24, 2016 1:18 pm
by Ormente
Klaus beat be while i was investigating the subject ;-)

Here is the stack a made to learn how to do it. There is two setProp handlers for myProperty : one on the stack, and one on the top button.

The one on the button would get fired only when setting myProperty for this object, but the one on the stack would run when setting myProperty for any object on the stack.

Re: Alert when custom properties value changed

Posted: Fri Jun 24, 2016 1:21 pm
by Klaus
Bonjour Ormente,
Ormente wrote:Klaus beat be while i was investigating the subject ;-)
get used to it, i work with LC and its predecessors since 1999, so this is no wonder :D


Best

Klaus

Re: Alert when custom properties value changed

Posted: Fri Jun 24, 2016 1:29 pm
by Ormente
@Klaus: I'm allready used to it... and i love it!

I gave a short try to LC in 2014, but i'm just learning it "seriously" now. Trying to answer questions helps me to learnderstand better... and you helped me too, by giving me the idea to put two setProp handlers to see how such "layering" works. It's very interesting. Thanks.

Re: Alert when custom properties value changed

Posted: Fri Jun 24, 2016 1:38 pm
by Klaus
Avec plaisir, mon ami!

Maybe my advantage (in using LC) was/is that I have no training in any other (more or less) serious programming language!
But I am good at logics and languages, so I can use the english like syntax easily to do whatever I want to do :D

Re: Alert when custom properties value changed

Posted: Fri Jun 24, 2016 1:49 pm
by shalu
many thanks to all for your wonderful responses :)