-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathdemo_event.v
62 lines (61 loc) · 1.76 KB
/
demo_event.v
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import ui
import gx
fn main() {
window := ui.window(
width: 600
height: 600
title: 'V UI: Event'
mode: .resizable
on_key_down: fn (w &ui.Window, e ui.KeyEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('key_down:\n${e}')
}
on_char: fn (w &ui.Window, e ui.KeyEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
s := utf32_to_str(e.codepoint)
tb.set_text('${*tb.text} \nchar: <${s}>\n${e}')
}
on_mouse_down: fn (w &ui.Window, e ui.MouseEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('mouse_down:\n${e}')
}
on_click: fn (w &ui.Window, e ui.MouseEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('${*tb.text} \nmouse_click:\n${e} \nnb_click: ${tb.ui.nb_click}')
}
on_mouse_up: fn (w &ui.Window, e ui.MouseEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('mouse_up:\n${e}')
}
on_mouse_move: fn (w &ui.Window, e ui.MouseMoveEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('mouse_move:\n${e}')
}
on_swipe: fn (w &ui.Window, e ui.MouseEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('swipe:\n${e}')
}
on_scroll: fn (w &ui.Window, e ui.ScrollEvent) {
mut tb := w.get_or_panic[ui.TextBox]('info')
tb.set_text('mouse_scroll\n${e}')
}
on_resize: fn (win &ui.Window, w int, h int) {
mut tb := win.get_or_panic[ui.TextBox]('info')
tb.set_text('resize:\n (${w}, ${h})')
}
layout: ui.row(
widths: ui.stretch
heights: ui.stretch
children: [
ui.textbox(
id: 'info'
mode: .multiline | .read_only
bg_color: gx.hex(0xfcf4e4ff)
// text: &app.info
text_size: 24
),
]
)
)
ui.run(window)
}