No mouse events during window file hovering event

Earlier today I was experimenting with the iced::window::Event::{FileHovered,FileDropped,FilesHoveredLeft} events from inside a custom widget and noticed that no iced::mouse::Event::CursorMoved events could be received while hovering the application window with a file. Is that normal behaviour, or is it me doing something wrong?

Note: I’m on macOS.

Thank you! :slight_smile:

So I dug a little deeper into the issue and found where/how, in the Iced code base, events are being “produced”. Based on iced/winit/src/conversion.rs, my understanding is that Iced events are simply a “remapping” of winit events. That being said, I now realize that my question has more to do with winit itself than with Iced.

So I ran a Google search for rust winit how to get cursor events while hovering file, and my first hit was Drag&Drop API / HoveredFile, DroppedFile, which corresponds to a GitHub issue (in the rust-windowing/winit repo) where the user exactly describes what I am observing.

I am just grouping the events together for now. It works well enough for dropping files.

Hey @AustinMReppert ,

Thanks for your reply! :slight_smile:

I haven’t had the chance to try what you shared, but I wanted to add that, although my initial post referred to capturing events from inside a custom widget, I have since been able to confirm that my issue is not widget-related: it occurs in the application’s update method as well.

So my problem was (and still is) that I wanted to keep receiving mouse events (e.g. CursorMoved) while hovering the application window with a file. But mouse events get suspended while hovering with a file. The link I posted above, in my second comment, suggests that it currently can’t be done with winit. But maybe different platforms behave differently. For instance, in my case I’m on macOS and it doesn’t work, but maybe it does work on Windows…

The events stop working while hovering. After a file is dropped, it will give you another cursor moved event. That should be enough if you just want to know where the file was dropped. If you need to know while it is being hovered, I think you will have to get the system mouse position separately.

1 Like