From: Fabian Y. <fa...@cs...> - 2005-12-29 19:49:15
|
hey! I'm currently writing my first program with wxhaskell, in fact, it's the first time I'm using haskell to write a program that goes beyond basic data-structures and sorting algorithms so I hope this question doesn't turn out to be non-wxhaskell specific. Basically, what I want to do is react on key-presses just like in the bouncing balls example or in this tutorial: http://www.cs.uu.nl/~daan/download/papers/wxhaskell.pdf. So I wrote the following: mainFrame = do cs <- variable [ value := (CSys (Rt start_ul start_lr))] f <- frame [] set f[ layout := space fwidth fheight , on paint := drawCoordSys cs fwidth fheight , text:= "Coordinate System" , on leftKey := do set cs [value :~ \x -> (csys_shift_x x (-(fac_x_p2t fwidth x))) ] repaint f ] return () where start_ul = (Pt (-4) 2) start_lr = (Pt 2 (-2)) fwidth = 800 fheight = 600 When leftKey is pressed, this is supposed to set the mutable variable cs and repaint f. This doesn't work for some reason. However, if I try the same with a timer, it works: t <- timer f [interval := 50 , on command := do set cs [value :~ \x -> (csys_shift_x x (-(fac_x_p2t fwidth x))) ] repaint f ] Any ideas? Thanks, - Fabian Yamaguchi |