events coming back to source

T

Tomba

Hi,

I have here a panel on which 3 controls are displayed. All of them show
some information of the same data object "Data". Every of the three
controls listens to changes in the Data object.

Now however, when the user clicks something in eg. control2, that
control for instance performs data.update(). Data then fires events,
which is ok except for control2 who doesn't need to be notified of
course as control2 itself was the cause of the event.

Now my question: how can I prevent control2 from acting on the event?
(in my example it may also be control1 or control3 of course).

Thanks a lot,
happy holidays

Steven De Groote
 
C

Chris Smith

Tomba said:
Now however, when the user clicks something in eg. control2, that
control for instance performs data.update(). Data then fires events,
which is ok except for control2 who doesn't need to be notified of
course as control2 itself was the cause of the event.

Now my question: how can I prevent control2 from acting on the event?
(in my example it may also be control1 or control3 of course).

Declare a boolean flag in control2. Set it to false. When you're
firing an event, set it to true just around the call that fires the
event, then set it false again right after. In the event handler, check
the flag, and return immediately when it's true.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top