on develop help sign in
Use keycode package instead of ad-hoc keycodes
commit581c8db6ff5196f490176691f2bda508da0ff659 authorRyan Trinkle <ryan.trinkle@gmail.com> dateSun 17 Jul 2016, 11:37 (10 years ago) parentbeb263a
4 files changed+29−24
default.nix+18−17 reflex-dom.cabal+2−1 src/Reflex/Dom/Class.hs+8−5 src/Reflex/Dom/Widget/Input.hs+1−1
default.nix+18−17
@@ -3,7 +3,7 @@
33, transformers, data-default, semigroups, blaze-builder, aeson
44, ghc, webkitgtk3-javascriptcore, exception-transformers
55, webkitgtk24x, dependent-sum-template, bifunctors, bimap
6−, raw-strings-qq, zenc, random, monad-control
6+, raw-strings-qq, zenc, random, monad-control, keycode
77}:
88
99mkDerivation {
@@ -11,26 +11,27 @@ mkDerivation {
1111 version = "0.3";
1212 src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
1313 buildDepends = [
14− reflex
15− dependent-map
16− mtl
17− transformers
18− these
19− lens
20− ghcjs-dom
21− text
22− data-default
23− semigroups
24− ref-tf
25− blaze-builder
2614 aeson
27− exception-transformers
28− dependent-sum-template
2915 bifunctors
30− zenc
31− random
3216 bimap
17+ blaze-builder
18+ data-default
19+ dependent-map
20+ dependent-sum-template
21+ exception-transformers
22+ ghcjs-dom
23+ keycode
24+ lens
3325 monad-control
26+ mtl
27+ random
28+ ref-tf
29+ reflex
30+ semigroups
31+ text
32+ these
33+ transformers
34+ zenc
3435 ] ++ (if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk3-javascriptcore raw-strings-qq ]);
3536 pkgconfigDepends = if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk24x webkitgtk3-javascriptcore raw-strings-qq ];
3637 license = null;
reflex-dom.cabal+2−1
@@ -50,7 +50,8 @@ library
5050 zenc == 0.1.*,
5151 bifunctors >= 4.2 && < 6,
5252 bimap >= 0.3 && < 0.4,
53− monad-control >= 1.0.1 && < 1.1
53+ monad-control >= 1.0.1 && < 1.1,
54+ keycode == 0.2.*
5455
5556 if impl(ghcjs)
5657 hs-source-dirs: src-ghcjs
src/Reflex/Dom/Class.hs+8−5
@@ -1,27 +1,30 @@
11{-# LANGUAGE MultiParamTypeClasses #-}
22module Reflex.Dom.Class ( module Reflex.Dom.Class
33 , module Foreign.JavaScript.TH
4+ , module Web.KeyCode
45 ) where
56
7+import Data.Map (Map)
8+import qualified Data.Map as Map
69import Reflex.Class
10+import Web.KeyCode
11+
12+import Foreign.JavaScript.TH
713import Reflex.Dom.PerformEvent.Class
814import Reflex.Dom.PostBuild.Class
915
1016import Prelude hiding (concat, mapM, mapM_, sequence)
1117
12−import Foreign.JavaScript.TH
13−
14−import Data.Map (Map)
15−import qualified Data.Map as Map
16−
1718-- | Alias for Data.Map.singleton
1819(=:) :: k -> a -> Map k a
1920(=:) = Map.singleton
2021infixr 7 =: -- Ought to bind tighter than <>, which is infixr 6
2122
23+{-# DEPRECATED keycodeEnter "Instead of `x == keycodeEnter`, use `keyCodeLookup x == Enter`" #-}
2224keycodeEnter :: Int
2325keycodeEnter = 13
2426
27+{-# DEPRECATED keycodeEscape "Instead of `x == keycodeEscape`, use `keyCodeLookup x == Escape`" #-}
2528keycodeEscape :: Int
2629keycodeEscape = 27
2730
src/Reflex/Dom/Widget/Input.hs+1−1
@@ -104,7 +104,7 @@ textInput (TextInputConfig inputType initial eSetValue dAttrs) = do
104104
105105{-# INLINABLE textInputGetEnter #-}
106106textInputGetEnter :: Reflex t => TextInput t -> Event t ()
107−textInputGetEnter i = fmapMaybe (\n -> if n == keycodeEnter then Just () else Nothing) $ _textInput_keypress i
107+textInputGetEnter i = fmapMaybe (\n -> if keyCodeLookup n == Enter then Just () else Nothing) $ _textInput_keypress i
108108
109109data TextAreaConfig t
110110 = TextAreaConfig { _textAreaConfig_initialValue :: Text