Raise a Event and Catch a Event multiple

  1. 7 months ago

    Markus R

    1 Nov 2019 Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 7 months ago

    i have a window with a list and one entry i can edit in a new window.
    this edit window have a container control with a event "AfterSaved"

    if me open this new edit window i try to use the add handler in the list window but i got a exeption there
    "Attempting to add a handler for an event that was already handled."
    i will handled it where i want and so often i want.

    AfterSaved is also used in the Edit Form self, the ContainerControl send it to his Window so the Window will be closed there.

    exists something like global events?
    example: i can raise a event "Hello" with arguments somewhere and all other places can receive this?

  2. Tim H

    1 Nov 2019 Portland, OR USA

    If you have implemented the AfterSaved event in the window, you need to re-raise the event in your AfterSaved code.

    sub AfterSaved()
        // do some stuff before forwarding the event to the outside world
        RaiseEvent AfterSaved
        // do some stuff afterward
    end sub

    The event system gives you precise control over when in your code the additional handler code will execute.

  3. Markus R

    1 Nov 2019 Testers, Xojo Pro Europe / Germany / Lower Saxon...

    thanks, i will play with it soon at next day

  4. Markus R

    2 Nov 2019 Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 7 months ago

    @Tim H re-raise the event

    i guess your meaning was a new event definition with the same nane in the edit form where the container control is placed?

    now i used a extra event definition only for my list update in the container control that i can use add handler in the window with my list. it was not my intend but it works.

  5. @Markus R example: i can raise a event "Hello" with arguments somewhere and all other places can receive this?

    For reference, please see this thread. https://forum.xojo.com/20267-delegates-events-and-objects-oh-my/0

or Sign Up to reply!