Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell SOEGraphics window wont close

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.

like image 253
Craig Innes Avatar asked Nov 04 '22 15:11

Craig Innes


1 Answers

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.

like image 108
DuckMaestro Avatar answered Nov 09 '22 07:11

DuckMaestro