Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: set_cursor shortcut" #357

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions crates/components/src/cursor_area.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dioxus::prelude::*;
use freya_common::EventMessage;
use freya_elements::elements as dioxus_elements;
use freya_hooks::use_platform;
use winit::window::CursorIcon;
Expand Down Expand Up @@ -46,23 +47,27 @@ pub fn CursorArea<'a>(cx: Scope<'a, CursorAreaProps<'a>>) -> Element<'a> {
to_owned![platform];
move |_| {
*is_hovering.write_silent() = true;
platform.set_cursor(icon);
platform.send(EventMessage::SetCursorIcon(icon)).unwrap();
}
};

let onmouseleave = {
to_owned![platform];
move |_| {
*is_hovering.write_silent() = false;
platform.set_cursor(CursorIcon::default());
platform
.send(EventMessage::SetCursorIcon(CursorIcon::default()))
.unwrap();
}
};

use_on_unmount(cx, {
to_owned![is_hovering];
move || {
if *is_hovering.read() {
platform.set_cursor(CursorIcon::default());
platform
.send(EventMessage::SetCursorIcon(CursorIcon::default()))
.unwrap();
}
}
});
Expand Down
6 changes: 1 addition & 5 deletions crates/hooks/src/use_platform.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dioxus_core::ScopeState;
use freya_common::EventMessage;
use tokio::sync::mpsc::UnboundedSender;
use winit::{event_loop::EventLoopProxy, window::CursorIcon};
use winit::event_loop::EventLoopProxy;

#[derive(Clone)]
pub struct UsePlatform {
Expand All @@ -28,10 +28,6 @@ impl UsePlatform {
}
Ok(())
}

pub fn set_cursor(&self, cursor_icon: CursorIcon) {
self.send(EventMessage::SetCursorIcon(cursor_icon)).ok();
}
}

pub fn use_platform(cx: &ScopeState) -> UsePlatform {
Expand Down