TextField loses Cursor

I am creating a custom textfield…
if the user makes an error I change the background color to red, and textcolor to white
on the next keystroke I reset the colors to white and black, but at the time the cursor seems to vanish, the control still “works”, but no cursor