I'm trying to make a text control that allows only letters and spaces, and changes letters to underscores as you type. So if you typed "abc123 def", you would see "___ ___" appearing.

I thought the solution would be controlOnText, which is nice because it works with both keyboard input and pasting. The problem is it also gets called when I change the text using set. For example here's a simple program that just reads the text and sets it again:

module Main where
import Graphics.UI.WX
import Graphics.UI.WXCore

main = start $
    do f <- frame []
       input <- textEntry f []
       controlOnText input $ update input
        update input =
            do txt <- get input text
               set input [text := txt]

This doesn't work because it results in an infinite loop. In wxPython I can use ChangeValue instead of SetValue to change the text without creating an event, but I can't find anything like that in wxHaskell. Is there another way to do this?