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

Author Topic: Text input C#  (Read 5980 times)

0 Members and 1 Guest are viewing this topic.

Joshua Booker

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Text input C#
« on: January 04, 2016, 04:33:48 am »
Hello,
I am working on a game engine, and have created a text entry dialog, but cannot get text to display correctly in my text object, it seems that the character codes are not being properly passed through correctly or I just don't know how to make it work, and require assistance. If anyone feels compelled to help, code is attached.


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Text input C#
« Reply #1 on: January 04, 2016, 02:35:13 pm »
Use the TextEntered event for text input. The KeyEventArgs.code is an enum for keys that only correspond to internal values (not any standards such as ANSI or Unicode).
« Last Edit: January 04, 2016, 02:36:59 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Joshua Booker

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Text input C#
« Reply #2 on: January 05, 2016, 04:57:47 am »
Not working, should I use Keypressed and keyreleased to get and save the char.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Text input C#
« Reply #3 on: January 05, 2016, 02:58:46 pm »
Quote
Not working

Not working how? You need to be specific. Post a complete and minimal example (don't just upload your code and ask us to find the issue). The TextEntered event is what you need to use for text input.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Joshua Booker

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Text input C#
« Reply #4 on: January 06, 2016, 03:33:49 am »
Ok, here is what I have a problem with now, the input is stored however the text disappears after a key is pressed, and that's annoying so how do I remedy that?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Text input C#
« Reply #5 on: January 06, 2016, 02:11:42 pm »
There is no way for me to know that, since it is a logic error in your code that is something you must figure out. If you have never used the debugger now is the perfect time to learn.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

 

anything