The answer to this question interest me very much as well.
Did you find something to work around this issue ?
EDIT: Forget it. I had an idea and searched the API for a solution. Turns out there’s a very easy one. Check this out:
Rocket::Core::Context* context = _levelUi.GetContext();
if (context->GetHoverElement() != context->GetRootElement())
return ;
You just have to put something like this in your Panda3D callback for mouse clicking.
It checks the current hovered element for a libRocket’s context: if it is different to the root of said context, then one of your document is hovered and you must intercept the event.
I’m not sure how you would do that with the Python bindings, but I suppose it’s doable.
Has someone found a pythonic solution for this? Pandas Python-reference doesn’t list any of those functions, although I assume, that they exist. The official API reference is only in C++ as well.
Currently, I use the following code:
python, general UI-Code:
@classmethod
def addCoverRegion(cls,name,box):
UI.coverRegions[name]=box
@classmethod
def removeCoverRegion(cls,name):
del UI.coverRegions[name]
@classmethod
def isOnUI(cls,x,y):
for r in UI.coverRegions.itervalues():
if(x>=r[0] and x<r[2] and y>=r[1] and y<r[3]):
return True
return False
Click-Event:
def mouse1(self):
if base.mouseWatcherNode.hasMouse():
if UI.isOnUI(base.win.getPointer(0).getX(),base.win.getPointer(0).getY()):
return
<regular code>
The div-element catched all clicks on it and then calls the UI function which was formerly called through a Panda event. Other UI elements have a higher z-index and thus the function is only called for locations, that don’t have other UI elements on top of it, i.e. the gamefield. This also allows for resizing / relocating of all other elements, without updating any code.
I know this thread is a few months old, but if anyone else is interested there’s a shorter way. Python does indeed have the required c++ bindings, they’re just written strangely.