Let a canvas::Program
control the mouse cursor
This commit is contained in:
parent
0509710cc5
commit
52719c7076
@ -210,7 +210,7 @@ impl<Message, P: Program<Message>> Widget<Message, Renderer>
|
||||
.collect(),
|
||||
}),
|
||||
},
|
||||
MouseCursor::Idle,
|
||||
self.program.mouse_cursor(size),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::canvas::{Event, Geometry, Size};
|
||||
use iced_native::MouseCursor;
|
||||
|
||||
pub trait Program<Message> {
|
||||
fn update(&mut self, _event: Event, _bounds: Size) -> Option<Message> {
|
||||
@ -6,6 +7,10 @@ pub trait Program<Message> {
|
||||
}
|
||||
|
||||
fn draw(&self, bounds: Size) -> Vec<Geometry>;
|
||||
|
||||
fn mouse_cursor(&self, _bounds: Size) -> MouseCursor {
|
||||
MouseCursor::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, Message> Program<Message> for &mut T
|
||||
@ -19,4 +24,8 @@ where
|
||||
fn draw(&self, bounds: Size) -> Vec<Geometry> {
|
||||
T::draw(self, bounds)
|
||||
}
|
||||
|
||||
fn mouse_cursor(&self, bounds: Size) -> MouseCursor {
|
||||
T::mouse_cursor(self, bounds)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user