SFML community forums

Help => System => Topic started by: amdlintuxos on June 25, 2011, 10:27:58 pm

Title: warning comparison beetwen enums
Post by: amdlintuxos on June 25, 2011, 10:27:58 pm
Greeting all.
Actually that is not a big issue (code works fine), but compiler(g++) gives me a warnings and i have feeling that i am doing something not exactly correct.


Code: [Select]

        if (g_EVENT.Type == sf::Event::MouseButtonPressed)
        {
           if (g_EVENT.Key.Code == sf::Mouse::Left)              
              g_MOUSE_LEFT_BUTTON = true;

           if (g_EVENT.Key.Code == sf::Mouse::Right)
              g_MOUSE_RIGHT_BUTTON = true;
        }

And here what compilers says.

Quote

keyEventsInSpace.cpp:190:47: warning: comparison between ‘enum sf::Key::Code’ and ‘enum sf::Mouse::Button’
keyEventsInSpace.cpp:193:47: warning: comparison between ‘enum sf::Key::Code’ and ‘enum sf::Mouse::Button’


I know that is just a warnings and i may switched off those, but i am new in C++ and want to learn how to do things right.


Many thanks for attention in advance.
Title: warning comparison beetwen enums
Post by: OniLinkPlus on June 26, 2011, 01:37:14 am
Event.Key is for KEYBOARD events, not Mouse events. Use Event.MouseButton instead.
Title: warning comparison beetwen enums
Post by: amdlintuxos on June 26, 2011, 10:53:44 am
OniLink10
Thanks, that solved my problem.
Quote

if (g_EVENT.MouseButton.Button == sf::Mouse::Left)