diff options
author | 2023-06-09 21:53:54 +0200 | |
---|---|---|
committer | 2023-06-09 21:53:54 +0200 | |
commit | 60cd864d43be877a5eaee4f5ca32f41b9fb70b79 (patch) | |
tree | 01a7758d3b8a4d2434bba113df85c6cb2c3e2ca2 /examples/modal | |
parent | c15f1b5f6575792cc89bb5fba2e613428397e46a (diff) | |
parent | 27639c4ce6161fa07986c2f1d472a8a259ae2129 (diff) | |
download | iced-60cd864d43be877a5eaee4f5ca32f41b9fb70b79.tar.gz iced-60cd864d43be877a5eaee4f5ca32f41b9fb70b79.tar.bz2 iced-60cd864d43be877a5eaee4f5ca32f41b9fb70b79.zip |
Merge pull request #1904 from iced-rs/cursor-availability
Cursor availability
Diffstat (limited to 'examples/modal')
-rw-r--r-- | examples/modal/src/main.rs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs index 9e1e4c2f..5c43c203 100644 --- a/examples/modal/src/main.rs +++ b/examples/modal/src/main.rs @@ -1,10 +1,11 @@ +use iced::executor; +use iced::keyboard; +use iced::subscription::{self, Subscription}; +use iced::theme; use iced::widget::{ self, button, column, container, horizontal_space, row, text, text_input, }; -use iced::{ - executor, keyboard, subscription, theme, Alignment, Application, Command, - Element, Event, Length, Settings, Subscription, -}; +use iced::{Alignment, Application, Command, Element, Event, Length, Settings}; use self::modal::Modal; @@ -254,7 +255,7 @@ mod modal { state: &mut widget::Tree, event: Event, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, renderer: &Renderer, clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, @@ -263,7 +264,7 @@ mod modal { &mut state.children[0], event, layout, - cursor_position, + cursor, renderer, clipboard, shell, @@ -277,7 +278,7 @@ mod modal { theme: &<Renderer as advanced::Renderer>::Theme, style: &renderer::Style, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, viewport: &Rectangle, ) { self.base.as_widget().draw( @@ -286,7 +287,7 @@ mod modal { theme, style, layout, - cursor_position, + cursor, viewport, ); } @@ -312,14 +313,14 @@ mod modal { &self, state: &widget::Tree, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, viewport: &Rectangle, renderer: &Renderer, ) -> mouse::Interaction { self.base.as_widget().mouse_interaction( &state.children[0], layout, - cursor_position, + cursor, viewport, renderer, ) @@ -377,7 +378,7 @@ mod modal { &mut self, event: Event, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, renderer: &Renderer, clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, @@ -389,7 +390,7 @@ mod modal { mouse::Button::Left, )) = &event { - if !content_bounds.contains(cursor_position) { + if !cursor.is_over(content_bounds) { shell.publish(message.clone()); return event::Status::Captured; } @@ -400,7 +401,7 @@ mod modal { self.tree, event, layout.children().next().unwrap(), - cursor_position, + cursor, renderer, clipboard, shell, @@ -413,7 +414,7 @@ mod modal { theme: &Renderer::Theme, style: &renderer::Style, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, ) { renderer.fill_quad( renderer::Quad { @@ -434,7 +435,7 @@ mod modal { theme, style, layout.children().next().unwrap(), - cursor_position, + cursor, &layout.bounds(), ); } @@ -456,14 +457,14 @@ mod modal { fn mouse_interaction( &self, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, viewport: &Rectangle, renderer: &Renderer, ) -> mouse::Interaction { self.content.as_widget().mouse_interaction( self.tree, layout.children().next().unwrap(), - cursor_position, + cursor, viewport, renderer, ) |