aboutsummaryrefslogtreecommitdiff
path: root/tut6_7_2.icl
blob: dadf8e9d8423c722a11a100730332a99a8f68b40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module tut6_7_2

// ********************************************************************************
// Clean tutorial example program.
//
// This program monitors keyboard input that is sent to a Window.
// ********************************************************************************

import StdEnv, StdIO

Start :: *World -> *World
Start world
# (wid, world)      = openId world
# window            = Window "Mousespotting" NilLS [
                        WindowMouse (const True) Able (noLS1 (spotting wid)), 
                        WindowId wid, 
                        WindowClose (noLS closeProcess)]
= startIO SDI Void (snd o openWindow Void window) [ProcessClose closeProcess] world
where
    spotting :: Id x (PSt .l) -> PSt .l | toString x
    spotting wid x pst = appPIO (setWindowLook wid True (False, look (toString x))) pst

    look :: String SelectState UpdateState *Picture -> *Picture
    look text _ {newFrame} picture
    # picture           = unfill newFrame picture
    # (width, picture)  = getPenFontStringWidth text picture
    = drawAt {x=(w-width)/2,y=h/2} text picture
    where
        {w,h}           = rectangleSize newFrame