Nifty: how to intercept mouse clicks

@t0neg0d not sure I am following: What Nifty method are you talking about? Look at my simple code above (after I took off almost everything and left just one small menu), even that doesn’t work.

Right, I just did your reading for you.

Open the nifty bible. Go to page 64. Read the section on Element Controllers.

Now jump to page 69. Read the element controller example.

Pay particular attention to the last paragraph.

@Nifty Bible said:
Changing the return value of an interaction method to boolean and returning true prevents calling
any other methods.

Step 1. Try that from a screen controller - have the onClick event boolean onClick() { return true; }

Step 2. If that didn't work then create an ElementController and do the same.

Report back and let us know what did/didn't work.

@zarch I figured out the problem, it’s about how I am intercepting the clicks it’s about WHEN

by debugging it the LeftClick() jMonkey method is being called BEFORE the next() method ur talking about , now I need to figure out how to fix that !

EDIT: even from the jME side if I use the CollisionResults to get the first collision (and if GUI ignore it) but it skips it directly.


There have been some issues with the way visibleToMouse works in the Nifty version you’re probably using right now. In the upcoming 1.3.2 Nifty it has been simplified as explained in detail in this commit on github.

There have been other changes for other input consuming issues as well and in 1.3.2 you can better control when and where events will be consumed. So this whole event consuming business will soon work better and hopefully more predictable. I’m currently in the process to add a new example to the control demonstration that will be used to show and test all of this.

1 Like