Why would you expect that output? The accept method just tells the game to do something when it sees a button is pressed later on. There’s no way to order that by what order you call the methods, especially not when the accept()s are being called on completely different classes.
You’ll probably have to write your own class to store the events and then run a task to order them how you want before calling the methods.
But I’m more confused as to why you need to do this at all? Couldn’t you just have a single DirectObject class that controls all events? You would then control the order of the methods in a wrapper method passed to the DirectObject. E.g. you would do something like this
class Controller(DirectObject):
pass
def mouse1down():
foo2.onDown()
foo1.onDown()
def mouse1up():
foo1.onUp()
foo2.onUp()
c = Controller()
c.accept("mouse1",mouse1down)
c.accept("mouse1-up",mouse1up)
But obviously mouse1down and mouse1up would be methods of a relevant class.
Thanks for your answer, Tober. I guess I thought accept worked like tasks do where they have priority of execution. I was trying to wrap a module which has its own accept calls and was hoping not to have to restructure anything. Yours is the simplest solution however.