Blinking Cursor Position

BlitzMax Forums/BlitzMax Beginners Area/Blinking Cursor Position

YellBellzDotCom(Posted 2011) [#1]
Hello!
I am currently using home made text boxes in my game GUI. When the user clicks a text box, I show a blinking cursor for the text input position. The problem I'm having is getting the cursor to show up at the proper position based on what text the user has typed. I am using a custom font with a size of 20. Does anyone have a formula for figuring the font width of letters and numbers and converting that to pixels so I can draw the blinking cursor in the correct position?

Thanks for any help!


Brucey(Posted 2011) [#2]
The TextWidth() function might help you here.


GfK(Posted 2011) [#3]
I simply add a flashing underscore ( _ ) (or whatever) character onto the end of the string before printing. For my requirements it didn't need to be any more complicated than that.


Perturbatio(Posted 2011) [#4]
TextWidth is what I used in the draw method of openconsole, did the trick nicely (it's posted on the forum somewhere). (in openconsole you can go back and forward through the text to edit what you've typed, so putting it on the end of the string was no good).


YellBellzDotCom(Posted 2011) [#5]
Ahhh thank you!
I will give that a shot.
Adding it to the end of the string is a very good idea, but I want it to blink. Great idea though!

Thank you very much!


Zeke(Posted 2011) [#6]
simple input:



GfK(Posted 2011) [#7]
Adding it to the end of the string is a very good idea, but I want it to blink
Mine does. I have a global 10hz timer. If timer.ticks() Mod 10 > 5 then I add the cursor. Otherwise, I don't. Simples.


YellBellzDotCom(Posted 2011) [#8]
Ahhh, thanks for the replies.

I appreciate the help. All I had to do is use the textWidth() command and it worked perfectly.
Thanks!