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

Author Topic: in-game console, inputting text.  (Read 4986 times)

0 Members and 1 Guest are viewing this topic.

phraze

  • Newbie
  • *
  • Posts: 6
    • MSN Messenger - phraze@gmail.com
    • View Profile
in-game console, inputting text.
« on: May 20, 2009, 11:25:55 am »
Hey, im new to SFML, and pretty new to c++.

Im currently writing on the ingame console for a game,
and im having problems figuring out how to make the text-input part.

Do i need to write some type of keymapsystem ?

Any help or maybe links to tutorials would be highly appreciated!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
in-game console, inputting text.
« Reply #1 on: May 20, 2009, 11:36:17 am »
SFML / OS X developer

phraze

  • Newbie
  • *
  • Posts: 6
    • MSN Messenger - phraze@gmail.com
    • View Profile
in-game console, inputting text.
« Reply #2 on: May 21, 2009, 08:39:31 pm »
Quote from: "Hiura"
Use TextEntered event ( ? ) http://www.sfml-dev.org/tutorials/1.5/window-events.php


Okay, im going crazy about this.
How do you get exactly what is entered by text-entered ?

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
in-game console, inputting text.
« Reply #3 on: May 21, 2009, 08:55:25 pm »
From the tutorial:

Code: [Select]
sf::Event Event;
while (App.GetEvent(Event))
{
    // Window closed
    if (Event.Type == sf::Event::Closed)
        Running = false;

    // Escape key pressed
    if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
        Running = false;
}
Listen to my band: pencilcase.bandcamp.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
in-game console, inputting text.
« Reply #4 on: May 21, 2009, 09:35:44 pm »
Wrong. Keypress events are for key press, not for text input.

Code: [Select]
sf::Event Event;
while (App.GetEvent(Event))
{
    // Character entered
    if (Event.Type == sf::Event::TextEntered)
    {
        sf::Uint32 unicode = Event.Text.Unicode;
        ...
    }
}

What to do then with the unicode character depends on what encoding you use. If you're using ASCII, you can just cast it to char if its value is less than 128.
Laurent Gomila - SFML developer

 

anything