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

Author Topic: Simplle way to implement an input field  (Read 1760 times)

0 Members and 2 Guests are viewing this topic.

CTryn

  • Newbie
  • *
  • Posts: 5
    • View Profile
Simplle way to implement an input field
« on: April 09, 2012, 03:35:12 pm »
Hello again!

What's the simplest way to implement an input field similar to those used in windows applications
(like the adress bar of your browser)?

I'd like to use this in a screen to be able to write a text (like a typical chat would look like in a game).
Is there a way without having to program every tiny aspect of how such bars behave so I don't have to
check for, let's say shift+a to write a capital A and a without shift to write a lower case letter, etc.

I apologize in case this is not a sfml-related question because there's no way to do it with sfml and therefore it doesn't belong here but in that case I'd appreciate some hints.

Thanks in advance,
Trynox

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Simplle way to implement an input field
« Reply #1 on: April 09, 2012, 03:45:29 pm »
A minimalistic SFML-only approach could use sf::Text for the text, sf::RectangleShape for the border and sf::Event::TextEntered for input.

For more sophisticated input boxes, you could take a look at a GUI library for SFML. In the project forum you find two active projects (SFGUI and TGUI), but some time ago there has been a complete list. Unfortunately it's a little bit outdated and all the forum links are dead. The wiki itself has also moved.
« Last Edit: April 09, 2012, 03:47:12 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Simplle way to implement an input field
« Reply #2 on: April 09, 2012, 03:47:17 pm »
SFML has no GUI (graphical user interface) elements.
So no there is no easy way to do it with SFML.
You could use diffrent libraries like Qt, which provide exactly what you want, although I'm not sure how good those two will work together.
On the other hand there is SFGUI which is an advanced GUI system. Since it's still in development (but stable) you can't expect all details you know of normal GUI interfaces.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CTryn

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Simplle way to implement an input field
« Reply #3 on: April 09, 2012, 03:59:36 pm »
Thanks both of you! I'll check those libraries out ;).

 

anything