Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,47 @@ main = do
}
```

You can also control the window loop to indicate webviewhs how to process each frame:

```haskell
{-# LANGUAGE
OverloadedStrings
#-}

import qualified Graphics.UI.Webviewhs as WHS

main :: IO ()
main = do
eitherWindow <- WHS.createWindow windowParams windowCallback
case eitherWindow of
Left _ -> pure ()
Right window -> do
windowLoop window
WHS.terminateWindowLoop window
WHS.destroyWindow window
where
windowParams = WHS.WindowParams
{ WHS.windowParamsTitle = "Test"
, WHS.windowParamsUri = "https://lettier.github.io"
, WHS.windowParamsWidth = 800
, WHS.windowParamsHeight = 600
, WHS.windowParamsResizable = True
, WHS.windowParamsDebuggable = True
}

-- This can be called from Html/JS as "window.external.invoke(msg)"
windowCallback window msg = print msg

-- Process a single frame using iterate
windowLoop window = do
shouldContinue <- WHS.iterateWindowLoop window False
if shouldContinue
then $ do
threadDelay 10000 -- wait some microsecs before next frame
windowLoop window
else pure ()
```

If you want more control over the native desktop window, you could do something like this:

```haskell
Expand Down