-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmenutest.nim
44 lines (32 loc) · 974 Bytes
/
menutest.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import macros
macro menuBar(x, y, w, h: float, body: untyped) =
for n in body:
if n.kind == nnkCall and n[0].kind == nnkStrLit:
echo $n[0]
result = quote do:
echo `x`
echo `y`
echo `w`
echo `h`
let
x = 12.0
y = 42.0
var h = 20.0
menuBar(x, y, 500, h):
"File":
if menuParentItem("&New", some(mkKeyEvent(keyN, {mkSuper}))):
if menuItem("&General"): echo "File -> New -> General"
if menuItem("&Open...", some(mkKeyEvent(keyO, {mkSuper}))):
echo "File -> Open"
"Help":
if menuItem("&Open...", some(mkKeyEvent(keyO, {mkSuper}))):
echo "File -> Open"
dumpTree:
"File":
if menuParentItem("&New", some(mkKeyEvent(keyN, {mkSuper}))):
if menuItem("&General"): echo "File -> New -> General"
if menuItem("&Open...", some(mkKeyEvent(keyO, {mkSuper}))):
echo "File -> Open"
"Help":
if menuItem("&Open...", some(mkKeyEvent(keyO, {mkSuper}))):
echo "File -> Open"