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

Cache mousemove and hook keyboard to allow scanning at mouse position while mouse is no longer moving #917

Merged
merged 1 commit into from
May 14, 2024

Conversation

Kuuuube
Copy link
Member

@Kuuuube Kuuuube commented May 12, 2024

Fixes #533

Something worth noting here is how the following interations work:

Interaction 1:

move mouse -> stop mouse -> scan -> close popup -> move mouse -> stop mouse -> scan

This works totally fine. Both times the user presses the button to scan they will get the popup and the word will be scanned.

Interaction 2:

move mouse -> stop mouse -> scan -> move mouse (first popup is not closed) -> stop mouse -> scan

This does not work. The user will get the first popup but then the second popup won't show (unless the user was scanning a word inside the first popup). This is because the user's browser will have focused inside the popup window and all event listeners outside of it can no longer access the keypresses.

On a normal webpage this wouldn't be an issue but Yomitan popups actually aren't even the same webpage. And a browser will not allow a webpage to access keystrokes being sent inside a different webpage. This behavior applies regardless of whether Yomitan is using a secure container and url or not.

Now this may raise the question of why moving the mouse before scanning while a different popup is open allows scanning with no problems. This is because modifier data can be accessed through mouse events and the browser will let those through since the mouse is hovering over the parent webpage with the event listener in it and not the popup's separate webpage.

@Kuuuube Kuuuube added kind/enhancement The issue or PR is a new feature or request area/ui-ux The issue or PR is related to UI/UX/Design labels May 12, 2024
@Kuuuube Kuuuube requested a review from a team as a code owner May 12, 2024 01:12
@Kuuuube Kuuuube added this to the Next Release milestone May 13, 2024
@jamesmaa jamesmaa added this pull request to the merge queue May 14, 2024
Merged via the queue into yomidevs:master with commit d60b010 May 14, 2024
10 checks passed
@phly95
Copy link

phly95 commented May 20, 2024

How do you bind a key to scan without moving the mouse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-ux The issue or PR is related to UI/UX/Design kind/enhancement The issue or PR is a new feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scan by single button press
4 participants