0

AnimationComponent.Subscribe() for keyboard events not clearing right

The subscribe and unsubscribe process:

AgentAnim.Subscribe("Key_F12", KeyPressed_F12, true);
...
AgentAnim.UnsubscribeFromEvent("Key_F12");

Keyboard handler:

private void KeyPressed_F12(string Name, ComponentId ComponentId) {
ScenePrivate.Chat.MessageAllUsers("Key pressed");
}

For each iteration of subscribe and unsubscribe, pressing the F12 key will cause duplicate firings while the subscription is active. The first time subscription happens, "Key pressed" will appear in chat history once when the user hits F12. The second time, twice. And so on.

.UnsubscribeFromEvent() does actually stop the events from firing, but it does not appear to actually clear the handler. So when it is reenabled, with a fresh call, the old event call resumes doing its thing.

2 comments

Please sign in to leave a comment.