Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


TextBox implementation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Plutonium   Members   -  Reputation: 349

Like
0Likes
Like

Posted 14 September 2013 - 05:50 PM

Hello, for some time making my game engine. Just as hobby to understand how games works smile.png

 

Now trying to make TextBox implementation, but really can't think any good implementation. While using XNA, I made property  "WriteWord": 

        public string WriteWord
        {
            get
            {
                string letter = string.Empty;
                Keys key = Key;
                if (key >= Keys.A && key <= Keys.Z && _writeWord.Length < 9)
                    letter = key.ToString();
                else if (key == Keys.Back && _writeWord.Length != 0)
                    _writeWord = _writeWord.Remove(_writeWord.Length - 1);
                _writeWord += letter;
                return _writeWord;
            }
        }

        public Keys Key
        {
            get
            {
                return
                    _pState.GetPressedKeys()
                           .FirstOrDefault(key => _pState.IsKeyDown(key)
						   && Keyboard.GetState().IsKeyUp(key));
            }
        }

and simple WriteWord value was set to TextBox value, and simply gets visual effect of typing and deleting. Maybe hard to understand how it works, and maybe not whole code where is, but it worked for my, having only one textBox (don't tested on more). But this implementation is not best... I think it's most worse as there can be smile.png

 

Now I using directInput and on keyDown I get codes like DIK_RIGHTARROW, DIK_1, DIK_S and so on... And for graphics - DirectX 9.

 

So, maybe somebody show how better implement TextBox? smile.png



Sponsor:

#2 swiftcoder   Senior Moderators   -  Reputation: 10361

Like
0Likes
Like

Posted 16 September 2013 - 04:25 PM

For various reasons, Microsoft decided to deprecate DirectInput several versions ago. The good news is that key translation is a whole lot simpler if you use the Windows message loop.

 

You might be interested in a relevant question on Stack Overflow.


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS