Not sure if this is just my way of working in Xojo or there is a better way to do it buuut… I would love to be able to define events in my classes and then subscribe to those events when I’m using these classes as another class property.
I have ClassFoo defining an event FooEvent
I have another class, ClassBar, which has a property “foo”, of type ClassFoo
Instead of adding handlers inside the constructor programatically, it would be nice to be able to right click on the property, just like in other places of the IDE, and handle the event from there
This would also require to be able to instantiate these properties as an option, like the “Implicit Instance” option in forms or pages.
As a first go, I guess, if you want to use this feature, your class is required to provide a plain constructor, without any parameter. Otherwise you have to do it programatically (that’s fine, it’s the way you have to do it at the moment anyway ¯\_(ツ)_/¯).
Then, for the weak address and so on, I think the IDE just have to follow the same rules it uses in the other places where you can add handlers visually.
And yep, for sure, this is just another feature request, for the long term, if it makes sense.
Would it work to make your classes subclasses of ContainerControl? You wouldn’t need any UI elements, or even really need to embed them on the window. But the IDE would expose the event structure for you.
Nice idea @Tim_Hare =), it doesn’t work for console apps but I’ll definitely give it a try to see if it’s a valid workaround for the way I use Xojo.
@Norman_Palardy here is the thing, if nobody asked for this before, it makes me think I’m trying to overuse the events or something. The reason is I’m trying to chain two or three shell command outputs, for example, in asynchronous mode, like using async/await in other languages, but probably it’s just better to put everything inside a thread and raise the last event when it finish.