no mouse ?!?!?!

well, i find problems REAL fast, so here’s the next one:

i wanted to do some tricks with a mouse, so i started to write code:

from pandac.PandaModules import *

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject

class World(DirectObject):

    def __init__(self):
      
      if base.mouseWatcherNode.hasMouse(): 
        print("true")
      else:
        print("false")

w=World()
run()

it only returns: “false” and i really have a mouse in my laptop.

and as my previous problem: i have no idea what the prob is.

mvg,

assainator

hasMouse only returns true if the mouse is inside the window (then its usable by Panda) and if the window has focus.

thanks again.
i’ll be back in… let’s say 5 min :stuck_out_tongue:

Seems to me that what you want to do is report when the mouseWatcherNode gains and loses the mouse. For that you’ll need a task. Try:

from pandac.PandaModules import *

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.task import Task

class World(DirectObject):
    def __init__(self):
        taskMgr.add(self.running,"running")

    def running(self, task):
        if base.mouseWatcherNode.hasMouse():
            print("true")
        else:
            print("false")
        return Task.cont

w=World()
run()

thank for the help, but no i didn’t want to do that.

mvg,

assainator