Skip to content

Commit

Permalink
Show NotAllowed as mouse icon when hovering a disabled TextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Apr 12, 2023
1 parent 1de794a commit 7e7e665
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/src/mouse/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pub enum Interaction {
Grabbing,
ResizingHorizontally,
ResizingVertically,
NotAllowed,
}
9 changes: 7 additions & 2 deletions native/src/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ where
_viewport: &Rectangle,
_renderer: &Renderer,
) -> mouse::Interaction {
mouse_interaction(layout, cursor_position)
mouse_interaction(layout, cursor_position, self.on_input.is_none())
}
}

Expand Down Expand Up @@ -1117,9 +1117,14 @@ pub fn draw<Renderer>(
pub fn mouse_interaction(
layout: Layout<'_>,
cursor_position: Point,
is_disabled: bool,
) -> mouse::Interaction {
if layout.bounds().contains(cursor_position) {
mouse::Interaction::Text
if is_disabled {
mouse::Interaction::NotAllowed
} else {
mouse::Interaction::Text
}
} else {
mouse::Interaction::default()
}
Expand Down
1 change: 1 addition & 0 deletions winit/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ pub fn mouse_interaction(
winit::window::CursorIcon::EwResize
}
Interaction::ResizingVertically => winit::window::CursorIcon::NsResize,
Interaction::NotAllowed => winit::window::CursorIcon::NotAllowed,
}
}

Expand Down

0 comments on commit 7e7e665

Please sign in to comment.