SFML community forums

General => General discussions => Topic started by: TULOA on June 06, 2011, 11:13:02 pm

Title: Question regaurding user input.
Post by: TULOA 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.
Title: Question regaurding user input.
Post by: Groogy 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.
Title: Question regaurding user input.
Post by: TULOA on June 07, 2011, 01:46:49 am
Ok but I was hoping for more of an example of how to use it.
Title: Question regaurding user input.
Post by: Groogy 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.
Title: Re: Question regaurding user input.
Post by: Nexus 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 ;)
Title: Question regaurding user input.
Post by: TULOA 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.
Title: Question regaurding user input.
Post by: keyforge on June 19, 2011, 05:22:54 am
You can download the latest SFML 2 snapshot on the downloads page (http://www.sfml-dev.org/download.php), 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.