Created
October 23, 2016 18:13
-
-
Save roSievers/78f0a533b047d295d549453ae3db49d5 to your computer and use it in GitHub Desktop.
OnRightClick can't be implemented using onWithOptions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (div, button, text) | |
import Html.App exposing (beginnerProgram) | |
import Html.Events exposing (onClick, onWithOptions) | |
import Json.Decode as Json | |
main = | |
beginnerProgram { model = 0, view = view, update = update } | |
view model = | |
div [] | |
[ button [ onRightClick Decrement ] [ text "-" ] | |
, div [] [ text (toString model) ] | |
, button [ onClick Increment ] [ text "+" ] | |
] | |
onRightClick message = | |
onWithOptions | |
"oncontextmenu" | |
{ stopPropagation = True | |
, preventDefault = True | |
} | |
(Json.succeed message) | |
type Msg = Increment | Decrement | |
update msg model = | |
case msg of | |
Increment -> | |
model + 1 | |
Decrement -> | |
model - 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment