How do you setup a mouse over & click response?

How do you setup a mouse over & click response?

OK so I can get an object to move with the mouse, how do I get a mouse over and click event to fire a python script? If you AND the two events together you can’t then pipe the output into a python script.

In other words how do I AND two sensor outputs into a python script?
Do I set some global property and then use logic in python or what?

Thanks for any help

Rob

2.25 lucky me!

put a condition in the functional part of the script

if sensor1.isPositive:
if sensor2.isPositive:
bla,bla,bla

or make a property that can be added by mouse over+mouse click event
and trigger the script when this prop changes

The first way is exactly what I wanted to do. I didn’t think it exsisted as when I did print dir() it only gave me two methods. So ispositive is a built in method? I feel like I am stumbling around in the dark on this, but it is interesting…well anyway I tried it and so far have not achieved sucess. This is what I did:

import Blender
import GameLogic
c = GameLogic.getCurrentController()
mouseL = c.getSensor(“mouseL”)
mouseR = c.getSensor(“mouseR”)
o = c.getOwner()
if mouseL.isPositive:
<indent> print “mouse left click”
if mouseR.isPositive:
<indent> print “mouse right click”

I don’t get any errors, it is just that it does not matter which button I click, both statements get printed, what am I missing, possibly my brain.

Thanks for any help again.

Rob.

isPositive is a function, or actually a method…

it should be written as

if sensor.isPositive():
<indent>#code

Carl

Great, the () did it.

Thanks,

Rob. :smiley:

Spoke too soon, when I create an exe isPositive() no longer works.

Any ideas, tried static & dynamic.
Trying to find doc on how to get a console window for debug…

Thanks,

Rob.

Try this…


mouseClick = controller.getSensor("mouseClick")
mouseOver = controller.getSensor("MouseOver")

if mouseClick.isPositive() and mouseOver.isPositive():
#do something!

Make sure your in a camera view- mouse over actions do not work otherwise!

peterw