Skip to content

Instantly share code, notes, and snippets.

@copygirl
Created August 14, 2018 13:42
Show Gist options
  • Save copygirl/148b127713d7fc132e736e32ec7bfc06 to your computer and use it in GitHub Desktop.
Save copygirl/148b127713d7fc132e736e32ec7bfc06 to your computer and use it in GitHub Desktop.
# input.nim
event InputEvent:
time: uint32
MouseDown, MouseUp:
mousePosition: Point
KeyUp, KeyDown:
keysym: KeySym
# In module 1
event Module1Event:
data1: int
data2: string
# In module 2
import
events,
module1,
input
subscribe Module1Event(data1: int, data2: string) =
[...]
# Both of the following would be equal?
subscribe InputEvent =
case event.kind
of MouseDown:
"[time: $1, pos: $2]" % [$event.time, $event.mousePosition]
subscribe InputEvent.MouseDown(time: uint32, mousePosition: Point) =
"[time: $1, pos: $2]" % [$event.time, $event.mousePosition]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment