Holding down a DirectButton

Hi, I was going to post this in the other recent DirectButton topic but that would have hijacked the thread. How can you get a DirectButton to do an action as long as it is held down? In my case I want it to spin the camera while it is clicked. I think I have a solution but the documentation is failing me right now.

What I have done so far is have the DirectButton start a task when it is clicked. The task then spins the camera while checking on the state of the DirectButton. However I can’t figure out how to check the state of the button. This thread says that DirectButton[‘state’] ought to work but when I try it all that comes out is the text ‘normal’. DirectButton[‘status’] doesn’t work either.

Is my approach correct and that there’s just something that I’m missing from the documentation? Or are there alternative approaches to this problem that I have yet to find?

Thanks for any help!

Doing a search brought up this topic with pretty much the same problem. I sorta like the solution of using DirectButton.bind() but my problem with it is I can’t seem to pass arguments with bind(). I could live with having two separate functions I suppose, I’m kind of in a rush but I would still like clarifications on how to read a button’s state.

Like coderedsim, I’m confused as to how to access DirectButton’s state. drwr mentions the four possible states of a DirectButton but doesn’t say how to get to them. I’m kinda holding out for a way to access these cause I like elegant code.

Once again, thanks for any help here!

EDIT:
Also, how did kampfgnu get events working with DirectButton’s?

You can try button.guiItem.isButtonDown() to query whether the button is being held down. You can also pass parameters through bind() with the extraArgs parameter. (But even if we didn’t provide an extraArgs parameter, you can always wrap your function up with its arguments with direct.showbase.PythonUtil.Functor.)

David