-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhow-do-i-open-a-save-dialog.hs
40 lines (37 loc) · 1.11 KB
/
how-do-i-open-a-save-dialog.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
{-
webviewhs
(C) 2018 David Lettier
lettier.com
-}
{-# LANGUAGE
OverloadedStrings
#-}
import Data.Text
import qualified Graphics.UI.Webviewhs as WHS
main :: IO ()
main = do
eitherWindow <-
WHS.createWindow
WHS.WindowParams
{ WHS.windowParamsTitle = "webviewhs - How do I open a save dialog?"
-- 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
let callback saveDialogResult = do
putStrLn $
"This is the save dialog result: "
++ Data.Text.unpack saveDialogResult
putStrLn "Done."
WHS.withWindowSaveDialog
window
"This is the window save dialog title."
callback