Ticket #1225: accel.hs

File accel.hs, 0.8 kB (added by guest, 3 years ago)
Line 
1import Graphics.UI.Gtk
2
3connectAction actg accg id accelerator command =
4    do  action <- actionNew id "" Nothing Nothing
5        actionGroupAddActionWithAccel actg action (Just accelerator)
6        actionSetAccelGroup action accg
7        actionConnectAccelerator action
8
9        on action actionActivated command
10
11        return action
12main =
13    do  initGUI
14        window <- windowNew
15
16        ag <- actionGroupNew "AGR"
17        ui <- uiManagerNew
18        acg <- uiManagerGetAccelGroup ui
19        uiManagerInsertActionGroup ui ag 0
20        windowAddAccelGroup window acg
21        connectAction ag acg "CLSE" "<Control>w" (putStrLn "Ctrl-W")
22        connectAction ag acg "TBAD" "<Control>t" (putStrLn "Ctrl-T")
23        connectAction ag acg "TBADs" "<Alt>1" (putStrLn "Ctasdrl-T")
24
25        onDestroy window mainQuit
26        widgetShowAll window
27
28        mainGUI