• Advertisement
Sign in to follow this  

Textbox cursor

This topic is 3514 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

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?

Share this post


Link to post
Share on other sites
Advertisement
How are you rendering your fonts, and do you have information available to you about the widths of each character?

Share this post


Link to post
Share on other sites
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.

Share this post


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

  • Advertisement