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

Author Topic: Question regaurding user input.  (Read 3675 times)

0 Members and 1 Guest are viewing this topic.

TULOA

  • Newbie
  • *
  • Posts: 4
    • View Profile
Question regaurding user input.
« on: June 06, 2011, 11:13:02 pm »
Is it possible to trigger an event or setup a listener on key up instead of key press?

For instance when they release the key it would add whatever key to the string. It would help for homemade user input for graphical programs. Otherwise I have to put in a delay so it isnt a million times a second >.<

I know C++ native has a WM_KEYUP or something like it.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Question regaurding user input.
« Reply #1 on: June 07, 2011, 12:22:57 am »
From the documentation: http://www.sfml-dev.org/documentation/1.6/classsf_1_1Event.php
Quote

enum EventType {
    ...
    TextEntered,
    KeyPressed,
    KeyReleased,  
    ...
}


Please try to find the answer yourself first before asking a question. Doing research on your own is always appreciated and is more or less a requirement in this profession.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

TULOA

  • Newbie
  • *
  • Posts: 4
    • View Profile
Question regaurding user input.
« Reply #2 on: June 07, 2011, 01:46:49 am »
Ok but I was hoping for more of an example of how to use it.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Question regaurding user input.
« Reply #3 on: June 07, 2011, 02:59:18 am »
Also from the tutorial: http://www.sfml-dev.org/tutorials/1.6/window-events.php

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

        // Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            App.Close();
    }
}


Just change KeyPressed to KeyReleased.

Seriously, try to look around first.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Question regaurding user input.
« Reply #4 on: June 07, 2011, 11:25:12 am »
Quote from: "TULOA"
Is it possible to trigger an event or setup a listener on key up instead of key press?
Polling events can be done in SFML. To setup listeners, you can use the thor::SfmlEventSystem class of my library ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TULOA

  • Newbie
  • *
  • Posts: 4
    • View Profile
Question regaurding user input.
« Reply #5 on: June 18, 2011, 11:53:53 pm »
Hurray a new issue....

I saw it discussed but is there any plans to fix or add a key for the Numpad Delete/Period Key?

Right now it isn't recognized and I have no idea how to edit SFML to include it for my project.

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Question regaurding user input.
« Reply #6 on: June 19, 2011, 05:22:54 am »
You can download the latest SFML 2 snapshot on the downloads page, edit the source code, and recompile the DLLs. A program called CMake can help you create the solution for your compiler of choice. Hopefully he will implement it eventually.
Need a place to upload your code, files or screenshots? Use SFML Uploads!