Problem with button control registered twice


i’ve got a set of screens, each with its own controller. when i go from the MainMenu screen to the MapGeneration screen, a tabgroup is created, and somme button are added to tabs (using java code, not defined in xml, as this is dynamic), to allow the user to change some values/properties. This works well.

However, if i got back to the main menu, and then back to the MapGeneration screen, then there is a problem with the buttons. each click is acting as if i made two click, as if the button was registered twice. i’ve got some code with a flag to be sure not to create the buttons twice (in the onStartScreen code) , but this is still occuring.I’ve checked th code, the method that create the buttons is called only once.

If i make a second pass (ie going again in the mainMenu, and then back to the Map generation screen), i still got the effect as 2 button registration and not 3, as i would have expected.

does anyone have this kind of problem ?


There are 2 mouse click events, one for button down, the other for button up. I think nifty always uses button down to fire an event. Either its using button up event as well (unlikely) or your registering your screens/controllers more than once, or something else. In the console, do you see 2 of these appear when you click the mouse down, or 4? To help distinguish between mouse moves, mouse clicks always have 0, 0 as the 3/4 integer value.

[java]15-Oct-2012 10:47:50 de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processMouseEvent

INFO: [processMouseEvent] [54, 232, 0, 0, true] processed [true]

15-Oct-2012 10:47:50 de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processMouseEvent

INFO: [processMouseEvent] [54, 232, 0, 0, false] processed [true][/java]

Try put some breakpoints down and see if code is getting executed more times than you think.

Post the critical code, or a testcase is even better.

1 Like

I can’t say I’ve seen that, although I don’t use the nifty tab control so maybe that is causing the problem?

1 Like

@zarch : it seems to be related to the tab, as you sugested. if i put buttons having the same effect (ie increasing/decreasing a displayed value), these buttons are reacting the correct way (increase / decrease by one), while the affected buttons that are present in a tab are reacting twice.

@wezrule : i’ll try to make a sample case this evening.

thanks to both