Textbox cursor

Started by
2 comments, last by marxxx 15 years, 9 months ago
I'm getting out of ideas, how to make a cursor to my text box? For example: this guy in the text form in posting >> | . Its about calculating how many pixels I need to move it forward, so it wouldn't run into another letter?
http://jklab.wordpress.com/ - Josef K. process laboratory
Advertisement
What are you using for your font?
How are you rendering your fonts, and do you have information available to you about the widths of each character?

- Jason Astle-Adams

I'm using SDL.NET with C#.
Tutorial I use for help is
http://www.geocities.com/egon_rath/sdl/sdlnet.html#truetypefonts

I have no information about the widths of letter, otherways iit would be simple :)

Here's some code about dealing with font.
m_PrimaryFont = new SdlDotNet.Graphics.Font(@"data/pfont.ttf", 16);

  private void KeyboardEventHandler(object sender, KeyboardEventArgs args)        {            if (m_bTextFocused == true) // If waiting for user text input            {                if (args.Down)                {                    if (args.Key == Key.Return && m_szPName.Length > 0)                    {                        m_bTextFocused = false;                        m_iGameStatus++;                    }                    else if (args.Key == Key.Backspace && m_szPName.Length > 0)                    {                        m_szPName = m_szPName.Remove(m_szPName.Length - 1);                    }                    else if (args.Unicode == 32)                    {                        m_szPName += " ";                    }                    else if ((args.Unicode >= 97 && args.Unicode <= 122) || (args.Unicode >= 65 && args.Unicode <= 90) || (args.Unicode >= 48 && args.Unicode <= 57))                    {                        m_szPName += args.UnicodeCharacter;                                         }                                  }            }            else // If waiting for system input            {                switch (args.Key)                {                    case Key.Escape:                        Events.QuitApplication();                        break;                }            }        }



        private void ApplicationTickEventHandler(object sender, TickEventArgs args)        {                m_Screen.Blit(m_PrimaryFont.Render(m_szPName, Color.Black), new Point(400, 230));                    m_Screen.Update(); // Flip surface        }


Ofcorse I have taken everything unimportant out.


I'm having problems also finding UI for BB tags in this forum, help about it would also be nice.
http://jklab.wordpress.com/ - Josef K. process laboratory

This topic is closed to new replies.

Advertisement