how to check the state of the mouse buttons

I need some sort of fuction or code that will let me check the state of the mouse buttons for example wether button 1 is pressed or unpressed.
i would really appreciate the help
thanks greatly.

Did you read the manual and API reference?
If not, you should do it!

Especially these pages, since they will answer your question:

According to the manual and API reference this will work:

base.mouseWatcherNode.isButtonDown( ) )

I put in the code in the program but it through an error at me saying

“name ‘MouseButton’ is not defined”

How do i go about fixing this

This message says that MouseButton is not imported. The API reference on this site tells you how to do that for each class. Following the link that enn0x gave:

you see on the top of the page:
from pandac.PandaModules import MouseButton

If you are lazy like me :wink: , you use:
from pandac.PandaModules import *

and everything in PandaModules is imported.

Hmm… understanding Python error messages is IMHO essential for Python coding, and thus for Panda3D coding.

I recommend reading the python tutorial before starting to play around with Panda3D, and not only chapter 8, the one about errors and exceptions. Working through the tutorial won’t take long, perhaps two or three hours.

Mousebuttons can be checked the same way as normal buttons on your keyboard.

accept("mouse1", executeCommand[1])
accept("mouse1-up", executeCommand[2])

But the others here are right, you HAVE TO read the manual. And at least use the search function of the forum, this is not the first question about how to use the mouse in Panda3D.
There’s also at least one tutorial that uses the mouse as input in your Panda3D installation (look into the folder “Samples”). At last that’s the way I got my mouse input working properly.