hello,
I'm dealing with the sfml events and have a problem that my application generates several KeyReleased events.
My pollEvent loop
while(rootWindow->pollEvent(event)) {
for(auto it : drawStack) {
if(it->eventable) {
it->handleEvent(event);
}
}
drawStack is a stack of pointers of objects that I want to draw on the screen.
The polled event should be forwarded to the respective objects, which then decide what happens.
handleEvent
void handleEvent(sf:: Event) {
switch(event.type) {
case sf::Event::KeyReleased:
cout << "obj 1 KeyReleased" << endl;
break;
}
}
everything works as long as there is only one object on the stack.
But with two objects on the stack I get such an output:
obj 1 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
...
This is what i want:
obj 1 KeyReleased
obj 2 KeyReleased
is my procedure right?
Is there another way to do it?
Or did I not understand sf :: Event?