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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! Menu widgets, properties and other types.
//!
//! ```no_run
//! use zng::prelude::*;
//! # APP.defaults().run_window("main", async {
//!
//! fn main_menu() -> UiNode {
//! Menu!(ui_vec![
//! SubMenu!(
//! "File",
//! ui_vec![
//! Button!(zng::app::NEW_CMD.scoped(WINDOW.id())),
//! Button!(zng::app::OPEN_CMD.scoped(WINDOW.id())),
//! Toggle! {
//! child = Text!("Auto Save");
//! checked = var(true);
//! },
//! Hr!(),
//! SubMenu!(
//! "Recent",
//! (0..10).map(|i| Button! {
//! child = Text!(formatx!("recent file {i}"));
//! })
//! ),
//! Hr!(),
//! Button!(zng::app::EXIT_CMD),
//! ]
//! ),
//! SubMenu!(
//! "Help",
//! ui_vec![Button! {
//! child = Text!("About");
//! on_click = hn!(|_| {});
//! }]
//! ),
//! ])
//! }
//!
//! Window! {
//! child_top = main_menu();
//! zng::app::on_new = hn!(|_| {});
//! zng::app::on_open = hn!(|_| {});
//! // ..
//! }
//! # });
//! ```
//!
//! The example above declares a [`Menu!`](struct@Menu) for a window, it demonstrates nested [`SubMenu!`](struct@sub::SubMenu),
//! and menu items, [`Button!`](struct@crate::button::Button),
//! [`Toggle!`](struct@crate::toggle::Toggle) and [`Hr!`](struct@crate::rule_line::hr::Hr). There is no menu item widget,
//! the `SubMenu!` widget re-styles button and toggle.
//!
//! # Context Menu
//!
//! This module also provides a context menu. The example below declares a context menu for the window, it will show
//! on context click, that is, by right-clicking the window, long pressing it or pressing the context menu key.
//!
//! ```
//! use zng::prelude::*;
//! # fn demo() {
//!
//! # let _ =
//! Window! {
//! context_menu = ContextMenu!(ui_vec![
//! Button!(zng::app::NEW_CMD.scoped(WINDOW.id())),
//! Button!(zng::app::OPEN_CMD.scoped(WINDOW.id())),
//! Toggle! {
//! child = Text!("Auto Save");
//! checked = var(true);
//! },
//! Hr!(),
//! SubMenu!(
//! "Help",
//! ui_vec![Button! {
//! child = Text!("About");
//! on_click = hn!(|_| {});
//! }]
//! ),
//! Hr!(),
//! Button!(zng::app::EXIT_CMD),
//! ]);
//! }
//! # ; }
//! ```
//!
//! # Full API
//!
//! See [`zng_wgt_menu`] for the full widget API.
pub use ;
use crate;
/// Default [`Menu!`] style.
///
/// Extends [`zng_wgt_menu::DefaultStyle!`] to cover more widgets. This is set as default in the `APP.default` using a window root extender.
///
/// [`Menu!`]: struct@Menu
/// [`zng_wgt_menu::DefaultStyle!`]: struct@zng_wgt_menu::DefaultStyle
;
/// Style applied to all [`TextInput!`] widgets inside [`Menu!`] root.
///
/// Gives the input a *toolbar-item* look.
///
/// [`TextInput!`]: struct@crate::text_input::TextInput
/// [`Menu!`]: struct@Menu
;
/// Submenu widget and properties.
///
/// See [`zng_wgt_menu::sub`] for the full widget API.
/// Context menu widget and properties.
///
/// See [`zng_wgt_menu::context`] for the full widget API.
/// Sub-menu popup widget and properties.
///
/// See [`zng_wgt_menu::popup`] for the full widget API.