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<http://hackage.haskell.org/packages/archive/wxcore/0.10.1/doc/html/Graphics-UI-WXCore-Events.html#v%3AcontrolOnText>,
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
    where
        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?
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

Reply via email to