-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhow-do-i-set-the-window-title.hs
39 lines (36 loc) · 1.18 KB
/
how-do-i-set-the-window-title.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
{-
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 title?"
-- This could be a localhost URL to your single-page application (SPA).
, WHS.windowParamsUri = "https://lettier.github.com"
, 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, change the window title.
threadDelay 2000000
WHS.dispatchToMain window $ \ window' ->
WHS.setWindowTitle window' "This is the new window title."
-- Run the window loop and block.
continue <- WHS.iterateWindowLoop window True
putStrLn $ "Could continue? " ++ show continue