Catch events on several forms
Posted
#1
(In Topic #818)
Regular

Posted
Guru

Posted
Regular

Posted
Guru

/comp/gb/observer - Gambas Documentation
/comp/gb/observer/_new - Gambas Documentation
Each form you want to catch an event of an object you can do something this…
Posted
Guru

BruceSteers said
Take a look at Observer.class
/comp/gb/observer - Gambas Documentation
/comp/gb/observer/_new - Gambas Documentation
Attached is a simple example.
on opening it opens 3 forms
all are set to monitor the test button of form1 , the Click event is reported in each forms label.
Notes.
Form1.btnTest had to have it's "Public" property set to True so it can be accessed by the other forms.
Posted
Guru

Notes..
Using Object.Attach will "Detach" the object from where it is attached to and has to be re-attached, Observer will intercept and only not trigger the original handler if using "Stop Event"
The Observer did not work on the main class, i had to make FMain.IslandFormObject a public object then use that on the Observers.
New Observer() takes a second argument "After" as Boolean to control if you want your observer to trigger before or after the main objects event is triggered.
Posted
Regular

BruceSteers said
Sorry i was a little low on time yesterday but had more time today, I have edited your posted project to use Observer.class
…
Thanks for the help!
Posted
Regular

1 guest and 0 members have just viewed this.


