[Fudgets Home Page]

An Up/Down Counter

This example shows how to handle input from more than one source.

Your browser doesn't support fupplets. Here is a window dump instead:

[Window dump of the Up/Down Counter]

The two buttons affect the same counter.

Here is the source code:

import Fudgets

main = fudlogue (shellF "Up/Down Counter" counterF)

counterF = intDispF >==< mapstateF count 0 >==<
           (buttonF "Up" >+< buttonF "Down")

count n (Left Click) = (n+1,[n+1])
count n (Right Click) = (n-1,[n-1])

Things to note

  • Next Example
  • Previous Example
  • Back to the Example list