Nifty GUI: get element under cursor

I’m racking my brain over this issue.
I have a strategy board game where I have set up a tooltip system that displays info based on the element that the cursor hovers over. This could be the terrain, a unit, or whatever in the 3D scene. It works like a charm.

EXCEPT

I’d like to disable the tooltips when a nifty gui element is under the cursor.
I use a fairly ancient version of Nifty GUI (1.4.0 snapshot), though i guess the whole thing is kinda antiquated by now anyway. Updating nifty is out of the question at this point.

I’ve tried everything I could think of:

  • Added an invisible panel at the very bottom with 100% screen coverage that enables the tooltips on hover and hides it when hovering ends. Unfortunately, the effect would not be ended by ANYTHING above it. I’ve tried the “visibleToMouse” option on the other layers and ALL elements and styles, not even elements that start their own hover effects would consume the hover of the bottom panel.

I used the effect with “nop” and onStartEffect & onEndEffect. It turns on and off properly based on the panel’s bounds, but like I said, nothing else affects it.

  • Tried searching for any API functionality on nifty for getting the topmost hovered element, or a list of hovered elements, ANYTHING. I found nothing.

  • Tried raycasting on the gui node. It became apparent that nifty doesn’t use the jme scenegraph system for its elements, so I am at a loss.

Any help would be very very very much appreciated, thanks!

I’m not sure if there is an easy way to do this or not. The easiest way to write a check that I can think of would be to walk the nifty scene graph and use the element.isMouseInsideElement method. If you have a defined panels that you know you want to check for blockage you can just call this on those elements and block accordingly.

I guess I’m desperate enough to do that now. It seemed like a wasteful insane idea at first, but i guess I haven’t had performance issues yet, so this shouldn’t break the camel’s back either.

After a quick test it seems to work. Thanks for the suggestion!

Yea, there are a lot of mitigating things you could do too like caching results. So if it was over an element last frame just check that same element first etc. I’m glad it helped!