Two different actions for the same DGG


Is it possible to bind twice the same DGG event to trigger two different actions ? From what I have tested the last one overwrites the previous.

Here is a small example :

frame = DirectFrame(...)
frame.bind(event=DGG.WITHIN, command=function_1)
frame.bind(event=DGG.WITHIN, command=function_2)

Is there a way to make this works, or I will need to manage the two actions in the same function?

Thanks for your help ! :smile:

Arguments are used for this purpose.

frame.bind(event = DGG.WITHIN, command = self.function_1, extraArgs = [False])

I’m not sure that this is also the right answer for you. Usually also use the if block.

1 Like

Hi Berthier,

As your tests have shown, and is my understanding also about the events system is that binding/accepting the same event as the same object will overwrite so it’s only the 2nd which will happen.

I’m not entirely sure what you’re trying to achieve though. Are you able to elaborate further on your intent please?

If you’re just trying to make the one event trigger 2 subsequent actions, why not just call them both from a single function triggered by the event?

def combined():

frame = DirectFrame(...)
frame.bind(event=DGG.WITHIN, command=combined)

Will something like the above not be suitable for your needs?

Curious to know more about what you’re trying to achieve.


1 Like

Thanks for your replies!

I ended up doing what @H3LLB0Y proposed, which best suites my needs! :wink:

1 Like