hello everyone!
i use my mouse to move around in my world.
i.e. on mouse-down i capture the mouseposition.
on mouseY > 0, i move forward, on mouseY < 0, i move backward,
on mouseX < 0 rotate left, on mouseX > 0 rotate right.
i also have collision objects in my world.
i would like to be able to doubleclick them and if doubleclicked, do something.
how do i recognise a doubleclick?
and like in my case, how do i prevent the first click to do something, but wait for a second click (lets say wait 50 milliseconds) ?
greets, kampfgnu
Are you still using my last code ?
It works this way :
def pickObj(self,lastMpos=None,t=None):
if not base.mouseWatcherNode.hasMouse(): return
if lastMpos:
mpos=lastMpos # LET'S USE THE LAST MOUSE POSITION,
# since there is possibility for the user
# to move around the mouse after the 1st click
else:
mpos = base.mouseWatcherNode.getMouse() # MOUSE POS RELATIVE TO RENDER2D
# MAKE IT RELATIVE TO THE DUMMY NODE WHOSE TRANSFORM REPRESENTS
# THE 3D DISPLAY REGION'S RELATIVE TRANSFORM TO RENDER2D
mpos=self.DR1dummy.getRelativePoint(render2d,Point3(mpos[0],0,mpos[1]))
if not(-1<mpos[0]<1 and -1<mpos[2]<1): # OUTSIDE 3D DISPLAY REGION
print 'YOU CLICKED OUTSIDE THE 3D DISPLAY REGION'
return
validDoubleClickTime=.2
elapsed=globalClock.getRealTime()-self.dblClickTime
if self.dblClickTime==0:
self.dblClickTime=globalClock.getRealTime()
taskMgr.doMethodLater(validDoubleClickTime,self.pickObj,'pickObj',extraArgs=[mpos])
return
self.dblClickTime=0
if elapsed>validDoubleClickTime: # SINGLE CLICK RESPOND, DO IT HERE
print 'RESPOND TO SINGLE CLICK'
return
# FROM THIS POINT FORWARD, IT'S DOUBLE CLICK RESPOND
print elapsed
if taskMgr.hasTaskNamed('pickObj'):
taskMgr.remove('pickObj') # BE SURE TO REMOVE THE SINGLE CLICK RESPOND
#Set the position of the ray based on the mouse position
self.pickerRay.setFromLens(base.camNode, mpos[0], mpos[2])
self.picker.traverse(render)
if self.pq.getNumEntries() > 0:
#if we have hit something, sort the hits so that the closest
#is first, and highlight that node
self.pq.sortEntries()
if self.picked!=None:
self.picked.clearColorScale()
self.pickedIval.setT(0) # somehow clearToInitial() didn't work
self.pickedIval.pause()
self.pickedIval=None
self.picked=self.pq.getEntry(0).getIntoNodePath().getParent()
self.picked.setColorScale(1,0,0,1)
self.pickedIval=self.picked.hprInterval(1,Vec3(360,0,0))
self.pickedIval.loop()
print 'GOT IT !'
else:
print 'YOU MISSED IT'
Define self.dblClickTime=0 in init
BTW, why are you using mouse click to change direction ? There are some FPS style camera movement codes on the forum, or in the Normal-Mapping tutorial, or Airblade.
yes of course i use your last code, it works perfect!!!
i use the mouseclick to move around because my boss wants to have that unhandy kind of control (he thinks its easier to use for “older” people, who don’t get along in doing both, pressing keys and using the mouse at the same time…lol).
just to make myself happy, i have a toggle key to change the controls 
thanks for your help again, i get addicted to panda3d more and more, not least because of its great forum and very helpful users like you are.
my first touch with 3dengines was ogre3d, but as i am not very good in c++, it took my days and weeks to just reach a single sub-goal.
panda3d rocks (and python, too)