Event Skiping

I am sorry if this has been discussed before but my search did not show anything specific to that.

How does one skip an event?

I want to make a button that when pressed will check if a criteria is met, if met then the command will be triggered, if not i want the command to be skiped. Basically i do not want direct button to continue executing the usual code when pressed.

i did bind my btn to DGG.B1PRESS

mybtn.bind(DGG.B1PRESS, myFunction)

def myFunction(evt):
      if criteria met:
          execute command
          mybtn.ignore('mouse1') #That did not work, i am guessing it is because the evt had already started by
#then, it might ignore a future one maybe but i want to ignore this one

Any help will be greatly appreciated thanks.

For those familiar with wxpython, i need something akin to evt.skip() to prevent the event from propagating further down the chain.


Maybe evt.Skip() can help you. given the evt is a WX event, this will cause the current event handler to be skipped and propagate the event up the widget hierarchy.

I am using DirectGui and not wxpython.
Does it have a similar function?


There’s unbind(), this will ignore the event not once, but until you bind() something back to that event.

unbind would not really help in my situation but i found a solution for those that might encounter that problem or need to do that.

I was binding the button with DGG.B1PRESS and the function that i needed.
It seems that the button command is launched with DGG.B1CLICK.

Both events it seems are triggered when a button is clicked or pressed/released, DGG.B1PRESS then DGG.B1CLICK (someone correct me if i am wrong on this.

When i bound DGG.B1CLICK to the function i wrote to check if the criteria is met or not i was able to decide if i want the button command to be executed or not.

The code looked like this:

myBtn is a subclass of DirectButton

self.bind(DGG.B1CLICK, self.click)

def click(self):
    if criteria met:
        apply(self['command'], self['extraArgs'])

thanks guys for your input.
I hope this will be helpful to someone.