Add macOS file association support for .ndbx files#529
Open
fdb wants to merge 2 commits intorewrite-in-rustfrom
Open
Add macOS file association support for .ndbx files#529fdb wants to merge 2 commits intorewrite-in-rustfrom
fdb wants to merge 2 commits intorewrite-in-rustfrom
Conversation
Support opening .ndbx files by dragging them onto the NodeBox window. Also modernize the macOS Info.plist: remove legacy Java entries, add UTExportedTypeDeclarations with a proper UTI (net.nodebox.ndbx) so macOS recognizes .ndbx files and shows NodeBox in "Open With" menus. On Windows, double-click file opening already works via CLI arguments. https://claude.ai/code/session_01NXut6FX3rsrwY1mDyjUadn
…o winit's delegate. winit 0.30.12's NSApplicationDelegate doesn't implement application:openFiles:, so macOS shows an error when double-clicking .ndbx files. This uses raw ObjC runtime calls (class_addMethod) to inject the method into the delegate's class during the eframe creation callback — after the delegate exists but before Apple Events are dispatched. File paths are stored in a global Mutex and polled each frame in update(). Handles both cold start (file double-clicked to launch app) and warm start (file double-clicked while app is already running). No new crate dependencies. https://claude.ai/code/session_01NXut6FX3rsrwY1mDyjUadn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for opening
.ndbxfiles on macOS through Finder double-clicks and drag-and-drop operations. It includes runtime injection of theapplication:openFiles:delegate method into winit's app delegate, along with proper file type declarations in the app bundle.Key Changes
New macOS file-open handler module (
macos_file_open.rs):application:openFiles:into winit's delegate class at runtimeMutex<Vec<PathBuf>>.ndbxextensionsUpdated Info.plist:
LSItemContentTypesto declare support fornet.nodebox.ndbxfile typeUTExportedTypeDeclarationsto define the customnet.nodebox.ndbxtype with proper conformance topublic.xmlandpublic.dataEnhanced app.rs:
open_dropped_file()method to handle file loading from both drag-and-drop and macOS file associationsUpdated lib.rs:
macos_file_openmodule (macOS-only)inject_file_open_handler()during app initializationImplementation Details
The solution works around winit 0.30.12's lack of
application:openFiles:support by:class_addMethod.ndbxdocumentshttps://claude.ai/code/session_01NXut6FX3rsrwY1mDyjUadn