Fix clipping of TextInput selection

This commit is contained in:
Héctor Ramón Jiménez 2024-01-12 13:34:14 +01:00
parent a5ae442819
commit 5315e04a26
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -1194,6 +1194,7 @@ pub fn draw<Renderer>(
(None, 0.0) (None, 0.0)
}; };
let draw = |renderer: &mut Renderer, viewport| {
if let Some((cursor, color)) = cursor { if let Some((cursor, color)) = cursor {
renderer.with_translation(Vector::new(-offset, 0.0), |renderer| { renderer.with_translation(Vector::new(-offset, 0.0), |renderer| {
renderer.fill_quad(cursor, color); renderer.fill_quad(cursor, color);
@ -1217,8 +1218,15 @@ pub fn draw<Renderer>(
} else { } else {
theme.value_color(style) theme.value_color(style)
}, },
text_bounds, viewport,
); );
};
if cursor.is_some() {
renderer.with_layer(text_bounds, |renderer| draw(renderer, *viewport));
} else {
draw(renderer, text_bounds);
}
} }
/// Computes the current [`mouse::Interaction`] of the [`TextInput`]. /// Computes the current [`mouse::Interaction`] of the [`TextInput`].