G4P: GTextField text modification

In this thread a similar issue is discussed. I modified my code so the color changes based on if it meets the regex or not. If there is a solution that would allow setText to work while the GTextField has focus I would really like to know about it.