Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


GUI TextBox help please...

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

Hi guys/gals, I''ve got a problem with my textbox. Basically, textbox is a static control with ability to edit text, right? So, the problem comes when a user clicks on the textbox and a caret appears - the problem is how to determine correct caret position using given text, font characters size (in units), and additional troubles like newlines in text, etc. So, how would I determine a position of a caret based on mouse X/Y position, font xSize and ySize, and textbox sizes xTextBox and yTextBox, and a text "Hello there\n How are you?".... Please help. Thanks. " Do we need us? "

Ionware Productions - Games and Game Tools Development

Share this post

Link to post
Share on other sites
It''s not that difficult, it''s only a lot of little work.

Basically, have a text wrapping function that produces the actual lines of text.

Either calculate for every line or assume one single line height.

Do all the little things and sum them up:

Y = yTextBox + all_visible_lines_from_top_of_textbox * lineheight;
x = xTextBox + letter_1_width + letter_2_width + ...

That''s all there is to it.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!