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
use crate::{api::prelude::*, proc_macros::*};
widget!(
/// The `Cursor` widget represents a text cursor that is used to mark text.
///
/// **style:** `cursor`
///
/// # Example
///
/// Create a cursor and share its text selection.
///
/// ```rust
/// Cursor::new().selection(id).build(ctx)
/// ```
Cursor {
/// Defines the selection of that cursor that is shared with the `TextBehavior`.
selection: TextSelection,
/// Defines the background of the whole selection range.
background: Brush,
/// Defines the brush of the text selection indicator.
border_brush: Brush,
/// Defines the with of the text selection indicator.
border_width: Thickness,
// Defines the opacity of the background of the selection range.
background_opacity: f32,
/// Defines the current width of the selection.
selection_width: f64,
/// Defines the start position of the current selection.
selection_x: f64,
/// Defines the x position of the cursor.
cursor_x: f64,
/// Defines the of the cursor.
offset: f64
}
);
impl Template for Cursor {
fn template(self, _: Entity, _: &mut BuildContext) -> Self {
self.name("Cursor")
.style("cursor")
.background_opacity(0.3)
.background("transparent")
.h_align("stretch")
}
fn render_object(&self) -> Box<dyn RenderObject> {
CursorRenderObject.into()
}
}