-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhow-do-i-set-the-windows-color.hs
48 lines (45 loc) · 1.53 KB
/
how-do-i-set-the-windows-color.hs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{-
webviewhs
(C) 2018 David Lettier
lettier.com
-}
{-# LANGUAGE
OverloadedStrings
#-}
import Control.Concurrent
import qualified Graphics.UI.Webviewhs as WHS
main :: IO ()
main = do
eitherWindow <-
WHS.createWindow
WHS.WindowParams
{ WHS.windowParamsTitle = "webviewhs - How do I set the window's color?"
-- This could be a localhost URL to your single-page application (SPA).
-- If a web page specifies a background color, setBackgroundColor will be
-- overridden.
, WHS.windowParamsUri = ""
, WHS.windowParamsWidth = 800
, WHS.windowParamsHeight = 600
, WHS.windowParamsResizable = True
, WHS.windowParamsDebuggable = True
}
-- This is the callback JavaScript can execute.
(\ _window text -> print text)
case eitherWindow of
Left e -> print e
Right window -> do
_ <- forkIO $ do
-- In two seconds, set the window's background color to green.
threadDelay 2000000
WHS.dispatchToMain window $ \ window' ->
WHS.setWindowBackgroundColor
window'
WHS.WindowBackgroundColor
{ WHS.windowBackgroundColorRed = 0
, WHS.windowBackgroundColorGreen = 255
, WHS.windowBackgroundColorBlue = 0
, WHS.windowBackgroundColorAlpha = 255
}
-- Run the window loop and block.
continue <- WHS.iterateWindowLoop window True
putStrLn $ "Could continue? " ++ show continue