Nifty Button Interact (better behavior onRelease?)

Hi there,



Try this out on this website (for example the Follow Button on the right hand side of the topics):

Click on a button on this page, but do not release your mouse button yet… then move away from the button and release after that. Do you notice that the Button has not been pressed? This is done on purpose. I miss this feature in Nifty Gui. When i click a button i move on to the next screenstate. Now this works fine but i didn’t even release the mousebutton. I want the action to be performed after i released the mousebutton on top of the element. Not just when i fire. Because now, when i have a Quitbutton on the same position in the next screen… and i move 1 px with my mouse and have this button still pressed… the application quits… just because nifty did not wait until release the mouse button. So i have to release really really quick to avoid this problem)!



Does anyone have a solution for this? I just want the action to be performed after i release a click on the button. Not just when i only click.

I expect you can modify the controls to give this behaviour…or add a screen transition effect of some kind that gives time for the mouse button to release and looks nifty…(all puns intended).

Ok, is there a little example on how to modify this interaction?

[xml]<interact onClick=“gotoMenu()” />[/xml]



So interactOnClick will not monitor a mousebuttonclick but a mousebuttonrelease?



For this time i solved the probled by just doing it this way:

[xml]<interact onRelease=“gotoMenu()” />[/xml]



In the meanwhile i’m looking to find a way to add the behavior… when i click on the button but release it outside the button, nothing should happen. But with onRelease the action is still being performed.

I agree with @niquedegraaff Nifty’s default behavior does not follow normal GUI behavior.



A click, either onRelease or onClick, should always be triggered if the mouse is still over the element. If it isn’t anymore, the action should be discarded.



Sadly, the only way I see to fix this is by modifying the Button.java class (or whatever class takes care of this). This is something I have the intention to look at at one point in time, but my todo list unrelated to my game is quite long and has low priority.

@niquedegraaff said:

In the meanwhile i'm looking to find a way to add the behavior.. when i click on the button but release it outside the button, nothing should happen. But with onRelease the action is still being performed.


I think you would need to do your own version of the button listener and check the mouse co-ordinates when they release. I've no idea off hand how easy that would be though as I'm still learning Nifty myself :)

Ok, thank you :wink: At least i pointed out this little issue :slight_smile: