Jump to content
  • Advertisement
Sign in to follow this  
JuliusDegutis

TextBox implementation

This topic is 2135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!