Take Rectangle by value in Cursor API

This commit is contained in:
Héctor Ramón Jiménez 2023-06-08 20:16:46 +02:00
parent 34451bff18
commit 5c8cfb411e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
21 changed files with 57 additions and 62 deletions

View file

@ -376,9 +376,7 @@ where
) -> event::Status {
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
let bounds = layout.bounds();
if cursor.is_over(&bounds) {
if cursor.is_over(layout.bounds()) {
if let Some(index) = *self.hovered_option {
if let Some(option) = self.options.get(index) {
*self.last_selection = Some(option.clone());
@ -388,7 +386,7 @@ where
}
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
if let Some(cursor_position) =
cursor.position_in(&layout.bounds())
cursor.position_in(layout.bounds())
{
let text_size = self
.text_size
@ -404,7 +402,7 @@ where
}
Event::Touch(touch::Event::FingerPressed { .. }) => {
if let Some(cursor_position) =
cursor.position_in(&layout.bounds())
cursor.position_in(layout.bounds())
{
let text_size = self
.text_size
@ -438,7 +436,7 @@ where
_viewport: &Rectangle,
_renderer: &Renderer,
) -> mouse::Interaction {
let is_mouse_over = cursor.is_over(&layout.bounds());
let is_mouse_over = cursor.is_over(layout.bounds());
if is_mouse_over {
mouse::Interaction::Pointer