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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Hork

Pages: [1]
1
Window / Re: TextEntered gives me mouse input. Is that intentional?
« on: January 28, 2017, 12:19:09 pm »
Oh, thank you!
I focused so much on the mouse thing, that i thought i just missunderstood the textentered event.

2
Window / TextEntered gives me mouse input. Is that intentional?
« on: January 28, 2017, 12:01:31 pm »
Hi there,

i just started to mess around with keyboard input. And i try to figure out a nice and clean way to get keyboardinput for some sort of typing game.

So i figured out how to filter the input a bit and how to get the inputs in need. But the problem i get is, that my mouse also produces keyboard input. These appear to be pretty random.
But the interesting thing is, that only produces input, when the mouse is on the left quarter of the SFML window.

I'm confused and not sure if this intentional. Any ideas?
Also: Do you think 'textentered' is the best solution when i need keyboardinput key by key for a typing game?

Here is the complete code i'm experimenting with:
#include <iostream>
#include "SFML\Graphics.hpp"


int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();

                        if (sf::Event::TextEntered)
                        {
                                if (event.text.unicode >= 32 && event.text.unicode <= 128)
                                {
                                        std::cout << "ASCII character typed: " << static_cast<char>(event.text.unicode) << std::endl;
                                }                      
                        }
                }

                window.clear();
                window.display();
        }

        return 0;
}

Pages: [1]
anything