3

I am using SDL and libfreetype and constructing a very basic GUI, I'm implementing a textBox, but I haven't been able to figure out how I'm supposed to generate the standard blinking cursor part. It doesn't seem to be exactly the same as a | character. And moreover if I draw it as a | character that changes the text width.

What's the canonically correct way to render text in a textbox with a cursor?

genpfault
  • 51,148
  • 11
  • 85
  • 139
OmnipotentEntity
  • 16,531
  • 6
  • 62
  • 96

1 Answers1

2

The easiest way is to just draw a line primitive, this gives you a lot more control over the spacing, length and width of the caret.

And if you want to keep it as a text character in your font system, you can do a render-to-texture and copy it out, or do a simple memory blit onto your font atlas (so you can can keep pipe character separate, an use a control char like 0x01 for the caret).

Necrolis
  • 25,836
  • 3
  • 63
  • 101