threepenny-gui 0.8.3.2 → 0.9.0.0
raw patch · 3 files changed
+54/−9 lines, 3 filesdep ~aesondep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, bytestring
API changes (from Hackage documentation)
+ Graphics.UI.Threepenny.Events: roundCoordinates :: (Double, Double) -> (Int, Int)
- Graphics.UI.Threepenny.Events: contextmenu :: Element -> Event (Int, Int)
+ Graphics.UI.Threepenny.Events: contextmenu :: Element -> Event (Double, Double)
- Graphics.UI.Threepenny.Events: mousedown :: Element -> Event (Int, Int)
+ Graphics.UI.Threepenny.Events: mousedown :: Element -> Event (Double, Double)
- Graphics.UI.Threepenny.Events: mousemove :: Element -> Event (Int, Int)
+ Graphics.UI.Threepenny.Events: mousemove :: Element -> Event (Double, Double)
- Graphics.UI.Threepenny.Events: mouseup :: Element -> Event (Int, Int)
+ Graphics.UI.Threepenny.Events: mouseup :: Element -> Event (Double, Double)
Files
- CHANGELOG.md +13/−0
- src/Graphics/UI/Threepenny/Events.hs +39/−7
- threepenny-gui.cabal +2/−2
CHANGELOG.md view
@@ -1,5 +1,18 @@ ## Changelog for the `threepenny-gui` package +**0.9.0.0** – Maintenance and snapshot release++* The events `contextmenu`, `mousedown`, `mousemove` and `mouseup` now return+ `Double` coordinates instead of `Int`s. This change reflects updates to the+ underlying browser APIs and the jQuery library. [#238][]++ Users who prefer to keep working with `Int` coordinates may use the added+ `roundCoordinates` compatibility function.++* Bump dependencies to allow `aeson` 1.5.++[#238]: https://github.com/HeinrichApfelmus/threepenny-gui/issues/238+ **0.8.3.2** – Maintenance release * Bump dependencies for compatibility with GHC-8.10.
src/Graphics/UI/Threepenny/Events.hs view
@@ -10,6 +10,9 @@ hover, leave, focus, blur, KeyCode, keyup, keydown, keypress,++ -- * Migration+ roundCoordinates ) where import Graphics.UI.Threepenny.Attributes@@ -43,7 +46,9 @@ click = silence . domEvent "click" -- | Context menu event.-contextmenu :: Element -> Event (Int,Int)+--+-- The mouse coordinates are relative to the upper left corner of the element.+contextmenu :: Element -> Event (Double,Double) contextmenu = fmap readCoordinates . domEvent "contextmenu" -- | Mouse enters an element.@@ -58,21 +63,48 @@ -- Note: The @<body>@ element responds to mouse move events, -- but only in the area occupied by actual content, -- not the whole browser window.-mousemove :: Element -> Event (Int,Int)+mousemove :: Element -> Event (Double,Double) mousemove = fmap readCoordinates . domEvent "mousemove" -readCoordinates :: EventData -> (Int,Int)+-- NB:+-- The return types of mouse events have been redefined from @long@+-- to @double@ in the CSS Object Model View Model working draft,+-- which browsers have begun to adopt.+-- See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent#Specifications+-- and https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageX+--+-- Similarly, we rely on jQuery's @.offset()@ to return+-- coordinates relative to the upper left corner of the+-- element, and this may return fractional data.+-- https://api.jquery.com/offset/+readCoordinates :: EventData -> (Double,Double) readCoordinates json = (x,y) where [x,y] = unsafeFromJSON json +-- | Round a pair of `Double` to the next integers.+-- This function helps you migrate from previous versions of Threepenny-GUI.+--+-- The return types of mouse events (`mousedown`, `mouseup`, `mousemove`, `contextmenu`) +-- have been redefined from @long@+-- to @double@ in the CSS Object Model View Model working draft,+-- which browsers have begun to adopt.+--+-- See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent#Specifications+--+-- and https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageX+roundCoordinates :: (Double,Double) -> (Int,Int)+roundCoordinates (x,y) = (round x, round y)+ -- | Mouse down event.--- The mouse coordinates are relative to the element.-mousedown :: Element -> Event (Int,Int)+--+-- The mouse coordinates are relative to the upper left corner of the element.+mousedown :: Element -> Event (Double,Double) mousedown = fmap readCoordinates . domEvent "mousedown" -- | Mouse up event.--- The mouse coordinates are relative to the element.-mouseup :: Element -> Event (Int,Int)+--+-- The mouse coordinates are relative to the upper left corner of the element.+mouseup :: Element -> Event (Double,Double) mouseup = fmap readCoordinates . domEvent "mouseup" -- | Mouse leaving an element.
threepenny-gui.cabal view
@@ -1,5 +1,5 @@ Name: threepenny-gui-Version: 0.8.3.2+Version: 0.9.0.0 Synopsis: GUI framework that uses the web browser as a display. Description: Threepenny-GUI is a GUI framework that uses the web browser as a display.@@ -110,7 +110,7 @@ cpp-options: -DREBUG ghc-options: -O2 build-depends: base >= 4.8 && < 4.15- ,aeson (>= 0.7 && < 0.10) || == 0.11.* || (>= 1.0 && < 1.5)+ ,aeson (>= 0.7 && < 0.10) || == 0.11.* || (>= 1.0 && < 1.6) ,async >= 2.0 && < 2.3 ,bytestring >= 0.9.2 && < 0.11 ,containers >= 0.4.2 && < 0.7