Closed ruoxiaomo closed 11 months ago
The file picker is not working correctly because the spotlight panel level is above that of the file picker level.
The solution is to reduce the spotlight panel level.
If you change that line to this:
panel.set_level(NSMainMenuWindowLevel);
or go lower to normal window level:
const NSNormalWindowLevel: i32 = 2;
panel.set_level(NSNormalWindowLevel);
it will work.
To add support for file picker upload, here are the steps to carry out:
panel.set_level(NSNormalWindowLevel)
, so that the file picker window can show on top of the spotlight windowpanel.set_auto_hide(false)
, this prevents the spotlight window from automatically hiding when it resigns as the key window (like blur).panel.set_level(NSMainMenuWindowLevel + 1)
.panel.set_auto_hide(true)
, so that the spotlight panel can auto-hide when it resigns as the key window.The full implementation can be found in the file-upload branch. See commit https://github.com/ahkohd/tauri-macos-spotlight-example/commit/536b35e382c2fc5f810963a2909f440260cc8630 (with explanations) which implements all the steps I mentioned above.
The file-upload example branch won't be merged to the main
branch. It will be maintained parallel along side with the main
branch, as uploading in a spotlight panel is not a very common use case.
Let me know if this solves your issue.
yeah
I have identified a bug:
When using
<input type="file">
to select a file, I am unable to choose a file from the popped-up Finder.Could this issue be addressed? Thank you! ❤️
My macOS version is 12.3.1.