-
Notifications
You must be signed in to change notification settings - Fork 130
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
support WindowEvent::DroppedFile #524
Conversation
src/window_handle.rs
Outdated
pub(crate) fn dropped_file(&mut self, path: PathBuf) { | ||
self.dropper_file = Some(path.clone()); | ||
self.event(Event::DroppedFile(DroppedFileEvent { path })); | ||
} | ||
|
||
pub(crate) fn pointer_move(&mut self, pos: Point) { | ||
if let Some(path) = self.dropper_file.take() { | ||
self.event(Event::DroppedFileWithPosition( | ||
DroppedFileWithPositionEvent { path, pos }, | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cursor position is stored in self.cursor_position
. So we should be able to send the dropped file event with the cursor position when the dropped file event was trigger from winit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried. It's not accurate. The mouse coordinates are not updated when you drag and drop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's something at winit's end. It should be fixed when this is implemented rust-windowing/winit#3833
Does it always emit pointer move after the file was dropped? If so, we don't need the drop file event without mouse position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, my observation is this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we just have one event DroppedFile
with both path and pos please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I just kept DroppedFileWithPositionEvent
rename |
No description provided.