Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: About ctrl + Left arrow  (Read 3252 times)

0 Members and 1 Guest are viewing this topic.

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
About ctrl + Left arrow
« on: March 12, 2010, 11:36:19 am »
I am tryin in events to take the ctrl+left arrow event. First press ctrl, then left  key.
How i can take this event?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
About ctrl + Left arrow
« Reply #1 on: March 12, 2010, 11:42:24 am »
Code: [Select]
if (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::Left && event.Key.Control)
{
    ...
}
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
About ctrl + Left arrow
« Reply #2 on: March 12, 2010, 12:25:54 pm »
As i see dont work ...

error: `event' was not declared in this scope

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
About ctrl + Left arrow
« Reply #3 on: March 12, 2010, 01:33:56 pm »
Well, this is not a complete code, you have to use this line into your event loop and adapt the variables names.
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
About ctrl + Left arrow
« Reply #4 on: March 12, 2010, 01:48:15 pm »
Ok i will try.
Thank's
Jim :)

---------------------------------------------------
trying ....

if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::LControl && Event.Key.Code == sf::Key::Left ){ ... }

dont work ...

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
About ctrl + Left arrow
« Reply #5 on: March 12, 2010, 03:12:52 pm »
Of course, the same variable can't have two values at once. Check for Control first, set a bool flag, check for Left. Reset the flag when releasing the key.

However, I think that realtime input (the sf::Input class) is more appropriate than events. How realtime input handling works is described in the tutorials.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
About ctrl + Left arrow
« Reply #6 on: March 12, 2010, 03:17:59 pm »
Quote
if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::LControl && Event.Key.Code == sf::Key::Left ){ ... }

dont work ...

Read my previous answer twice, this is not the code that I gave you.

Quote
Check for Control first, set a bool flag, check for Left. Reset the flag when releasing the key.

There's no need to do so, The Event::Key structure directly provides the state of modifier keys (Control, Alt, Shift).
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
About ctrl + Left arrow
« Reply #7 on: March 12, 2010, 06:36:14 pm »
Ok i will try to read and understud the structure...
Thank's
Jim