SFML community forums

Help => General => Topic started by: Razzeeyy on January 29, 2012, 02:27:09 pm

Title: messing up with key events <_<
Post by: Razzeeyy on January 29, 2012, 02:27:09 pm
Hi guys, what am I doing wrong?

Code: [Select]
               switch(Event.KeyEvent.Code)
                {
                    case sf::Key::Code::Num1:
                    {
                        SelectedColor=Black;
                        break;
                    }
                    case sf::Key::Code::Num2:
                    {
                        SelectedColor=Blue;
                        break;
                    }
                }


compiles with this error:
Quote
invalid use of ‘struct sf::Event::KeyEvent’


The Event object is obviously sf::Event Event..
Title: messing up with key events <_<
Post by: texus on January 29, 2012, 02:32:05 pm
Quote
Event.KeyEvent.Code

This should be "Event.Key.Code".

KeyEvent is the name of the struct, while Key is defined like this:
KeyEvent Key;
Title: messing up with key events <_<
Post by: Razzeeyy on January 29, 2012, 03:32:53 pm
Oh, yeah. Thank you! :)