summaryrefslogtreecommitdiff
path: root/examples/example_02_controls.nim
blob: 59cba009923e0e78cf158a82c47895e5c09d7815 (plain)
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
# This example shows several controls of NiGui.

import nigui

app.init()

var window = newWindow()

var container = newLayoutContainer(Layout_Vertical)
window.add(container)

# Add a Button control:
var button = newButton("Button")
container.add(button)

# Add a Label control:
var label = newLabel("Label")
container.add(label)

# Add a TextBox control:
var textBox = newTextBox("TextBox")
container.add(textBox)

# Add a TextArea control:
var textArea = newTextArea("TextArea\pLine 2\p")
container.add(textArea)

# Add more text to the TextArea:
for i in 3..15:
  textArea.addLine("Line " & $i)

# Add click event to the button:
button.onClick = proc(event: ClickEvent) =
  textArea.addLine("Button clicked")

window.show()

app.run()