Skip to content
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

Spotlight w/ file picker upload #12

Closed
ruoxiaomo opened this issue Nov 24, 2023 · 6 comments
Closed

Spotlight w/ file picker upload #12

ruoxiaomo opened this issue Nov 24, 2023 · 6 comments
Assignees
Labels

Comments

@ruoxiaomo
Copy link

ruoxiaomo commented Nov 24, 2023

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.

@ahkohd
Copy link
Owner

ahkohd commented Nov 25, 2023

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.

panel.set_level(NSMainMenuWindowLevel + 1);

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.

@ahkohd ahkohd self-assigned this Nov 25, 2023
@ahkohd
Copy link
Owner

ahkohd commented Nov 25, 2023

To add support for file picker upload, here are the steps to carry out:

  1. When you click the file upload button.
  2. Set the spotlight panel to normal window level, panel.set_level(NSNormalWindowLevel), so that the file picker window can show on top of the spotlight window
  3. Set panel.set_auto_hide(false), this prevents the spotlight window from automatically hiding when it resigns as the key window (like blur).
  4. Show the file picker window.
  5. Pick your file.
  6. Reset the spotlight window level back to above the main menu window level, panel.set_level(NSMainMenuWindowLevel + 1).
  7. Reset the panel.set_auto_hide(true), so that the spotlight panel can auto-hide when it resigns as the key window.

@ahkohd
Copy link
Owner

ahkohd commented Nov 25, 2023

Screen Recording 2023-11-25 at 9 05 46 PM

The full implementation can be found in the file-upload branch. See commit 536b35e (with explanations) which implements all the steps I mentioned above.

@ahkohd
Copy link
Owner

ahkohd commented Nov 25, 2023

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.

@ahkohd
Copy link
Owner

ahkohd commented Nov 25, 2023

Let me know if this solves your issue.

@ahkohd ahkohd changed the title The CSS hover effect is not working. When using <input type="file"> to select a file, I am unable to choose a file from the popped-up Finder. Spotlight w/ file picker upload Nov 26, 2023
@ahkohd ahkohd added the example label Nov 26, 2023
@ahkohd ahkohd pinned this issue Nov 26, 2023
Repository owner deleted a comment from ruoxiaomo Nov 26, 2023
@ruoxiaomo
Copy link
Author

ruoxiaomo commented Nov 27, 2023

yeah

Repository owner deleted a comment from ruoxiaomo Nov 27, 2023
Repository owner deleted a comment from ruoxiaomo Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants