Skip to content

Commit

Permalink
Merge pull request #44 from SkyLeite/main
Browse files Browse the repository at this point in the history
Make system cursor optional
  • Loading branch information
ArjunNair authored Sep 16, 2024
2 parents 2a21abc + 86f29e9 commit 9a1ab38
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ impl RepaintSignal for Signal {
}

pub struct FusedCursor {
pub cursor: Cursor,
pub cursor: Option<Cursor>,
pub icon: SystemCursor,
}

impl FusedCursor {
pub fn new() -> Self {
Self {
cursor: Cursor::from_system(SystemCursor::Arrow).unwrap(),
cursor: Cursor::from_system(SystemCursor::Arrow).ok(),
icon: SystemCursor::Arrow,
}
}
Expand Down Expand Up @@ -422,8 +422,10 @@ pub fn translate_cursor(fused: &mut FusedCursor, cursor_icon: egui::CursorIcon)
};

if tmp_icon != fused.icon {
fused.cursor = Cursor::from_system(tmp_icon).unwrap();
fused.cursor = Cursor::from_system(tmp_icon).ok();
fused.icon = tmp_icon;
fused.cursor.set();
if let Some(cursor) = &fused.cursor {
cursor.set();
}
}
}

0 comments on commit 9a1ab38

Please sign in to comment.