Uh, what would cause onAction to be called twice? When I press any button the keyboard, onAction is called twice :S.
i have the same issue… I have some Controls and i call them at onAction.
I solved it with checking if the control is enabled…
[java]
if (myControIsEnabled == false && KeyIsPessed == true) runControl();
[/java]
But i think there is a bug somewhere…
Of course you need the KeyIsPressed check. Otherwise it is clearly called twice like all Java ActionListeners. One time for pressing, one time for releasing. So its not a Bug. You just have to add the check.
You can find it even in the JME JavaDoc from the InputManager:
onAction
events are raised when the specific input activates or deactivates. For a digital input such as key press, theonAction()
event will be raised with theisPressed
argument equal to true, when the key is released,onAction
is called again but this time with theisPressed
argument set to false
@PhilipWilluweit said: Of course you need the KeyIsPressed check. Otherwise it is clearly called twice like all Java ActionListeners. One time for pressing, one time for releasing. So its not a Bug. You just have to add the check.You can find it even in the JME JavaDoc from the InputManager:
Ahh, didnt think about that…
Weird. It didn’t seem to be happening before and only noticed today haha. What a lemon, thanks :).