Improvements for cursor
This commit is contained in:
parent
405c77bb47
commit
e20552ad13
2 changed files with 18 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ use cosmic::iced_native::{
|
||||||
},
|
},
|
||||||
keyboard::{Event as KeyEvent, KeyCode},
|
keyboard::{Event as KeyEvent, KeyCode},
|
||||||
layout::{self, Layout},
|
layout::{self, Layout},
|
||||||
mouse::{Button, Event as MouseEvent, ScrollDelta},
|
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
||||||
renderer,
|
renderer,
|
||||||
widget::{self, Widget},
|
widget::{self, Widget},
|
||||||
};
|
};
|
||||||
|
|
@ -100,6 +100,21 @@ where
|
||||||
layout::Node::new(size)
|
layout::Node::new(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mouse_interaction(
|
||||||
|
&self,
|
||||||
|
_tree: &widget::Tree,
|
||||||
|
layout: Layout<'_>,
|
||||||
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
|
_renderer: &Renderer,
|
||||||
|
) -> mouse::Interaction {
|
||||||
|
if layout.bounds().contains(cursor_position) {
|
||||||
|
mouse::Interaction::Text
|
||||||
|
} else {
|
||||||
|
mouse::Interaction::Idle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
_state: &widget::Tree,
|
_state: &widget::Tree,
|
||||||
|
|
|
||||||
|
|
@ -476,7 +476,7 @@ impl<'a> TextBuffer<'a> {
|
||||||
f(
|
f(
|
||||||
x as i32,
|
x as i32,
|
||||||
line_y - font_size,
|
line_y - font_size,
|
||||||
(font_size / 2) as u32,
|
1,
|
||||||
line_height as u32,
|
line_height as u32,
|
||||||
0x20FFFFFF,
|
0x20FFFFFF,
|
||||||
);
|
);
|
||||||
|
|
@ -485,7 +485,7 @@ impl<'a> TextBuffer<'a> {
|
||||||
f(
|
f(
|
||||||
glyph.x as i32,
|
glyph.x as i32,
|
||||||
line_y - font_size,
|
line_y - font_size,
|
||||||
glyph.w as u32,
|
1,
|
||||||
line_height as u32,
|
line_height as u32,
|
||||||
0x20FFFFFF,
|
0x20FFFFFF,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue