Skip to content

Add Event::OpenFiles#3713

Closed
jim-ec wants to merge 1 commit intorust-windowing:masterfrom
jim-ec:master
Closed

Add Event::OpenFiles#3713
jim-ec wants to merge 1 commit intorust-windowing:masterfrom
jim-ec:master

Conversation

@jim-ec
Copy link
Copy Markdown
Contributor

@jim-ec jim-ec commented May 28, 2024

Emit an event when the application is opened by clicking on files in Finder or by dropping files on the Dock icon. This is macOS specific, as other OSs usually communicate that information through std::env::args().

I am not sure with the current implementation, i.e. maybe the OpenFiles event should be defined in a macOS specific event enum type?

This basically implements #1751.

To test the event, a application bundle is required:

Winit.App
- Contents
  - Info.plist
  - MacOS
    - <executable>

The Info.plist should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleExecutable</key>
    <string>
        <!-- Name of executable -->
    </string>
</dict>
</plist>

Also, you need to implement fn ApplicationHandler::open_files(&mut self, files: Vec<PathBuf>).

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated [feature matrix](https://github.com/rust-windowing/winit

@jim-ec jim-ec requested a review from madsmtm as a code owner May 28, 2024 17:11
Copy link
Copy Markdown
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be on its own trait as it was requested multiple times. The Event will be gone soon, so no need to add anything into it.

@madsmtm
Copy link
Copy Markdown
Member

madsmtm commented Jun 24, 2024

Thanks for the PR, though I'm going to resolve this in a different way, see #1751 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants