Not receiving any events or window focus

I’m on Mac osx 10.5.8
My panda3d.core.PandaSystem.getVersionString() is 1.7.0

I have a window made with ShowBase.openWindow()

This window is stored as a property of my wrapper, which is a subclass of DirectObject.

Thus I have:
self.win.hasPointer(0)
self.win.hasKeyboard(0)

These are both always true, regardless of the focus (which is what I want to know)

In my window wrapper;s init I have tried:

def test():
            print "event"
        
        self.accept("x",test)
        self.accept("k-up",test)
        self.accept("mouse1",test)
        self.accept("mouse1-up",test)
        base.accept("x",test)
        base.accept("k-up",test)
        base.accept("mouse1",test)
        base.accept("mouse1-up",test)

but none of the events ever fire.

I suspected wx of eating my events, so I took out everything wx related, and it does not seem to help.

I suspected closing my ShowBase main window might be an issue, so I tried leaving it open. Then I tried both at once. No difference.

The one thing that does cause these events to work (but still has no effect on self.win.hasPointer(0) and self.win.hasKeyboard(0) always being true) is to show the ShowBase main window, and give it the focus.

So:

  1. How can I tell if my window has the focus,
  2. How can I make it accepting events actually work without showing and selecting the ShowBase main window.
  3. How can I just capture all of the events automatically? (so I can use my own event handling system)

Thanks!

Edit: one more detail I have discovered: when the mouse is not over the window, the mouse x and y values(see code below) don’t change as the mouse moves (though it still claims to have the pointer). Odd. It seems if I click and drag off the edge, it keeps updating the mouse position as long as I clicking initially in my window (which I can’t detect clicks in).

data=self.win.getPointer(0)
x=data.getX()
y=data.getY()

Window focus is determined by examining win.getProperties().getForeground().

As to detecting keyboard events, you will need to set up a MouseAndKeyboard object for your window, and a ButtonThrower. If you also want to create DirectGui elements in your second window you will need more, like an aspect2d node. These are created by ShowBase for you automatically for your first window, but you have to do it yourself for additional windows. There are a few threads that describe this, for instance this one.

David

self.win.getProperties().getForeground() works as expected. Thanks!

That thread looks really helpful. Thanks! If I have any further issues, I’ll be back, but I think that should do it for this problem at least.