A small iced widget library that makes it easy to render a widget that follows the mouse cursor. :contentReference[oaicite:1]{index=1}
Add this to your Cargo.toml:
[dependencies]
iced = "0.14"
iced-mouse-layer = { git = "https://github.com/shim9610/iced-mouse-layer" }Create examples/quick_start.rs:
use iced::{Element, Length, Task, Theme};
use iced::widget::{column, container, text};
use iced_mouse_layer::mouse_layer;
#[derive(Debug, Clone)]
enum Message {}
#[derive(Default)]
struct App;
impl App {
fn title(&self) -> String {
"iced-mouse-layer quick start".into()
}
fn update(&mut self, _message: Message) -> Task<Message> {
Task::none()
}
fn view(&self) -> Element<'_, Message> {
let base = container(text("Move your mouse.")).padding(16);
let ghost = mouse_layer(
container(text("👻 MouseLayer"))
.padding(10)
)
.offset(15.0, 15.0);
column![base, ghost]
.width(Length::Fill)
.height(Length::Fill)
.into()
}
}
pub fn main() -> iced::Result {
iced::application(App::default, App::update, App::view)
.title(App::title)
.theme(Theme::Dark)
.run()
}Run:
cargo run --example quick_startRenders content at the mouse cursor position.
mouse_layer(text("Hello"))Sets the offset from the cursor. Default is (0.0, 0.0).
mouse_layer(text("Hello"))
.offset(10.0, 10.0)- Avoid using
Length::Fillinside themouse_layercontent. Prefer fixed sizes. - The layer may not be visible when the cursor is outside the window (platform/OS behavior).