Skip to content
Snippets Groups Projects
Commit 527644f3 authored by Gino Valente's avatar Gino Valente
Browse files

Removed default cursor on Text widget

Added show_cursor prop on Text widget to achieve same effect
parent bd9786d5
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,10 @@ pub struct TextProps { ...@@ -15,6 +15,10 @@ pub struct TextProps {
pub font: Option<String>, pub font: Option<String>,
/// The height of a line of text (currently in pixels) /// The height of a line of text (currently in pixels)
pub line_height: Option<f32>, pub line_height: Option<f32>,
/// If true, displays the default text cursor when hovered.
///
/// This _will_ override `cursor` values set by styles.
pub show_cursor: bool,
/// The font size (in pixels) /// The font size (in pixels)
/// ///
/// Negative values have no effect /// Negative values have no effect
...@@ -35,6 +39,7 @@ impl Default for TextProps { ...@@ -35,6 +39,7 @@ impl Default for TextProps {
content: String::new(), content: String::new(),
font: None, font: None,
line_height: None, line_height: None,
show_cursor: false,
size: -1.0, size: -1.0,
styles: None, styles: None,
on_event: None, on_event: None,
...@@ -70,6 +75,9 @@ pub fn Text(props: TextProps) { ...@@ -70,6 +75,9 @@ pub fn Text(props: TextProps) {
if let Some(ref font) = props.font { if let Some(ref font) = props.font {
styles.font = StyleProp::Value(font.clone()); styles.font = StyleProp::Value(font.clone());
} }
if props.show_cursor {
styles.cursor = StyleProp::Value(CursorIcon::Text);
}
if props.size >= 0.0 { if props.size >= 0.0 {
styles.font_size = StyleProp::Value(props.size); styles.font_size = StyleProp::Value(props.size);
} }
...@@ -77,8 +85,5 @@ pub fn Text(props: TextProps) { ...@@ -77,8 +85,5 @@ pub fn Text(props: TextProps) {
styles.line_height = StyleProp::Value(line_height); styles.line_height = StyleProp::Value(line_height);
} }
props.styles = Some(styles.with_style(&props.styles).with_style(Style { props.styles = Some(styles.with_style(&props.styles));
cursor: StyleProp::Value(CursorIcon::Text),
..Default::default()
}));
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment