-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_menu.cr
More file actions
50 lines (41 loc) · 964 Bytes
/
basic_menu.cr
File metadata and controls
50 lines (41 loc) · 964 Bytes
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
require "../../src/uing"
UIng.init
UIng::Menu.new("File") do
append_item("Open").on_clicked do |w|
Window.open_file
end
append_separator
append_preferences_item.on_clicked do |w|
w.msg_box("Preferences", "Preferences clicked")
end
append_separator
append_quit_item
end
UIng::Menu.new("Edit") do
append_check_item("Check", checked: false).on_clicked do |w|
# No-op
end
append_separator
append_item("Click").on_clicked do |w|
w.msg_box("Click", "Click menu clicked")
end
end
UIng::Menu.new("Help") do
append_about_item.on_clicked do |w|
w.msg_box("About", "Menu example")
end
end
# Window must be created after menu finalized.
Window = UIng::Window.new("Menu Example", 300, 50, menubar: true) do
on_closing do
UIng.quit
true
end
show
end
{% if flag?(:darwin) %}
label = UIng::Label.new("The Mac menu bar is at the top of the screen.")
Window.set_child(label)
{% end %}
UIng.main
UIng.uninit