Closed silentdth closed 12 years ago
This could possibly be a bug in SFML I'll have a look at it when I get some time.
Can you check if you get any event? Or is it just specifically Event::Closed?
I just retested it, It doesn't work for any events. I just tried Event::MouseLeft.
I know its the correct Event because I output it to the console.
EG:
puts event
produces
SFML::Event(MouseLeft)
then do something with a condition, like so:
if event === Event::MouseLeft puts "MADE IT!" window.close end
It never enters the conditional block.
Hope that helps.
This is interesting, using irb.
>> Event::MouseMove === Event::MouseMove
=> false
>>
And then...
>> Event::MouseMove == Event::MouseMove
=> true
Have you tried with the #== operator? I see there's a === operator for one of the event types classes(not instance method). I'll have a look at the code in SFML::Event and see what it is actually supposed to do. ^^
Interesting:
>> Event::MouseMove #== Event::MouseMove
=> SFML::Event::MouseMove
>> Event::Closed #== Event::Closed
=> #<SFML::Event::Type:0x200d228 @id=0>
Ok, thanks. I might be doing something wrong!
Erhm the "#" means the instance method :P
So if I write SFML::Event#== then that means the "==" method on an Event instance.
Though the thing I want you to try out is:
event.type == SFML::Closed
Though I think this might be wrong. Because you got an instance from writing: Event::Closed. Which is very wrong. I'll look at it when I get home.
Fixed in this commit f1e489bd482d009781fa739cf7a9534a11ae3422
Let me know if it works for you. Though remember: event == SFML::Event::Closed
is an invalid comparison. They are two different types. What you want to do is event.type == SFML::Event::Closed
. I could make so the first one works as well. Though the second one is the one we implemented as this is how it works in C++ SFML ;)
Thanks Groogy!
That works :)
Take the below code for example, if you close the window using the red 'X' (Windows 7 32bit) the event described with 'puts event' is 'Event::Closed', but the window does not close: