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
//! Identity, source, and interaction-flag modifiers for [`El`].
use std::panic::Location;
use super::node::El;
use super::semantics::{Kind, Source};
impl El {
pub fn new(kind: Kind) -> Self {
Self {
kind,
..Default::default()
}
}
// ---- Identity / source ----
pub fn key(mut self, k: impl Into<String>) -> Self {
self.key = Some(k.into());
self
}
pub fn block_pointer(mut self) -> Self {
self.block_pointer = true;
self
}
pub fn focusable(mut self) -> Self {
self.focusable = true;
self
}
/// Opt this node into the library's text-selection system. The
/// node must also carry an explicit `.key(...)`; selection requires
/// stable identity across rebuilds the same way focus does.
pub fn selectable(mut self) -> Self {
self.selectable = true;
self
}
/// Opt this node into raw key capture when focused. While this
/// node is the focused target, the library's Tab/Enter/Escape
/// defaults are bypassed and raw `KeyDown` events are delivered for
/// the widget to interpret. Implies `focusable`.
pub fn capture_keys(mut self) -> Self {
self.capture_keys = true;
self.focusable = true;
self
}
/// Multiply this element's paint opacity by the nearest focusable
/// ancestor's focus envelope.
pub fn alpha_follows_focused_ancestor(mut self) -> Self {
self.alpha_follows_focused_ancestor = true;
self
}
/// Multiply this node's paint opacity by the runtime's caret blink
/// alpha.
pub fn blink_when_focused(mut self) -> Self {
self.blink_when_focused = true;
self
}
/// Borrow hover and press visual envelopes from the nearest
/// focusable ancestor.
pub fn state_follows_interactive_ancestor(mut self) -> Self {
self.state_follows_interactive_ancestor = true;
self
}
pub fn at(mut self, file: &'static str, line: u32) -> Self {
self.source = Source { file, line };
self
}
/// Set source from a `Location` (used internally by
/// `#[track_caller]` constructors).
pub fn at_loc(mut self, loc: &'static Location<'static>) -> Self {
self.source = Source::from_caller(loc);
self
}
}