Alert when custom properties value changed

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Alert when custom properties value changed

Post by shalu » Fri Jun 24, 2016 11:53 am

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:
--
Thanks
Shalu S

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Alert when custom properties value changed

Post by Klaus » Fri Jun 24, 2016 12:31 pm

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

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm
Location: Near Mâcon, France

Re: Alert when custom properties value changed

Post by Ormente » Fri Jun 24, 2016 1:18 pm

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.
Attachments
setPropHandler.zip
(812 Bytes) Downloaded 198 times

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Alert when custom properties value changed

Post by Klaus » Fri Jun 24, 2016 1:21 pm

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

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm
Location: Near Mâcon, France

Re: Alert when custom properties value changed

Post by Ormente » Fri Jun 24, 2016 1:29 pm

@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.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Alert when custom properties value changed

Post by Klaus » Fri Jun 24, 2016 1:38 pm

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

shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Re: Alert when custom properties value changed

Post by shalu » Fri Jun 24, 2016 1:49 pm

many thanks to all for your wonderful responses :)
--
Thanks
Shalu S

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”