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
//! Right-click popup menu — elegance-styled context menu.
//!
//! [`ContextMenu`] opens a themed popup at the cursor position when its
//! anchor [`Response`] is secondary-clicked. The popup hosts the same
//! [`MenuItem`](crate::MenuItem), [`MenuSection`](crate::MenuSection),
//! and [`SubMenuItem`](crate::SubMenuItem) widgets as the rest of the
//! menu family, so the visual treatment matches both [`Menu`](crate::Menu)
//! popups and [`MenuBar`](crate::MenuBar) dropdowns.
//!
//! The target [`Response`] must have a click sense for egui to register
//! the secondary click — most interactive widgets (buttons, list rows
//! sensed via `Sense::click()`) already do; for plain labels or custom
//! regions, allocate the rect with `Sense::click()` first.
//!
//! ```no_run
//! # use elegance::{ContextMenu, MenuItem, MenuSection, SubMenuItem};
//! # egui::__run_test_ui(|ui| {
//! let row = ui.add(egui::Label::new("theme.rs").sense(egui::Sense::click()));
//! ContextMenu::new("file_row").show(&row, |ui| {
//! ui.add(MenuItem::new("Open").shortcut("\u{21B5}"));
//! ui.add(MenuItem::new("Open in new split").shortcut("\u{2318}\u{21E7}\u{21B5}"));
//! SubMenuItem::new("Open with").show(ui, |ui| {
//! ui.add(MenuItem::new("Source editor"));
//! ui.add(MenuItem::new("Preview"));
//! });
//! ui.separator();
//! ui.add(MenuSection::new("Edit"));
//! ui.add(MenuItem::new("Copy").shortcut("\u{2318}C"));
//! ui.add(MenuItem::new("Rename\u{2026}").shortcut("F2"));
//! ui.separator();
//! ui.add(MenuItem::new("Delete").danger().shortcut("\u{232B}"));
//! });
//! # });
//! ```
//!
//! The popup is dismissed by clicking any item, clicking outside, or
//! pressing `Esc`.
use Hash;
use ;
use crateTheme;
/// A right-click-anchored popup menu attached to a [`Response`].
///
/// See the module-level docs for usage. The menu opens at the cursor
/// position when `target` is secondary-clicked.