Librocket event error

Hello,

I’m using librocket/panda3d from the last devel version and it no longer works with librocket events.
(i’m on windows, but the error apear on linux too)

I was previously using a devel version of panda3d, without this problem.

The error:

Test
Traceback (most recent call last):
  File "C:\Panda3D-1.9.0\direct\showbase\ShowBase.py", line 1856, in __igLoop
    self.graphicsEngine.renderFrame()
KeyError: 'document'
:task(error): Exception occurred in PythonTask igLoop

The code generating the error:

def test():
      print "Test"
librocketElem.AddEventListener(event, test) # "event" can be 'click', etc...

What can cause this ?
Why is this apearing only in the last devel version of panda ?

Have a good day!

I checked, this error apears on:

  • Windows with “devel” version
  • Linux with “devel” version
  • Linux with “1.8.1” version

However, it does NOT appear on Windows with version “1.8.1”.

Any idea ?

I’m not too sure but I think I USED to get an error similar to that.

It was because I was trying to do stuff to libRocket (Like loading a document) before my game tick was running.

(Although I just tried removing my fix and it still runs ok…hmm.)

Anyway - I’m using libRocket with a fairly recent 1.9, and my events are attached ok, although I’m doing things a bit different:

e.AddEventListener("click","messenger.send('RocketClickElement', [event])", True)

The problem is that libRocket expects that you only use AddEventListener with a Python method that is defined in one of the tags, and not one that is defined in your application.
This is a bug in libRocket and should be patched there.

The way I worked around it was to put this:

event = None
self = None
document = None

at the top of the module where your callback function is defined. (This is because libRocket expects these three to be defined in the global scope of the callback function, which is always the case for functions defined in tags.)
It’s hacky, but it works until someone fixes the bug in libRocket.

Your example code updated:

event = None
self = None
document = None

def test():
      print "Test"
librocketElem.AddEventListener(event, test) # "event" can be 'click', etc...

Oh ok, I’ll do that, thank you for your help !

It’s a bit tricky indeed.