I am currently following the exercises the in the book: "The Haskell School of Expression" and have reached the third chapter on creating graphics. The book uses the SOEGraphics module and demonstrates drawing some simple text in a window and then closing it with a button press.
However, when after compiling and executing, I find that although the window appears with the text on screen, the window refuses to close regardless of which keys I press or whether the focus is on the command line or the window itself.
Here is the source code from the book:
module Main where
import SOE
main = runGraphics(
do w <- openWindow
"My First Graphics Program" (300, 300)
drawInWindow w (text(100,200) "HelloGraphicsWorld")
k <- getKey w
closeWindow w
)
The only way to get the window to close is by forcing it to quit with CTRL-C. Is there something I have overlooked with my code? The program was compiled using GHC 7.4.1 and was run on Ubuntu.
Try getKeyChar
intead of getKey
. There seems to have been a change in the preferred method to use and/or to the behavior in certain OSs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With