Improvements for cursor

This commit is contained in:
Jeremy Soller 2022-10-19 09:26:43 -06:00
parent 405c77bb47
commit e20552ad13
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
2 changed files with 18 additions and 3 deletions

View file

@ -7,7 +7,7 @@ use cosmic::iced_native::{
},
keyboard::{Event as KeyEvent, KeyCode},
layout::{self, Layout},
mouse::{Button, Event as MouseEvent, ScrollDelta},
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
renderer,
widget::{self, Widget},
};
@ -100,6 +100,21 @@ where
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(
&self,
_state: &widget::Tree,

View file

@ -476,7 +476,7 @@ impl<'a> TextBuffer<'a> {
f(
x as i32,
line_y - font_size,
(font_size / 2) as u32,
1,
line_height as u32,
0x20FFFFFF,
);
@ -485,7 +485,7 @@ impl<'a> TextBuffer<'a> {
f(
glyph.x as i32,
line_y - font_size,
glyph.w as u32,
1,
line_height as u32,
0x20FFFFFF,
);