feat(vncscreen.tsx): Allow for customization of onMouseEnter and onMouseLeave events #72
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.
Description
Currently the VncScreen component has hardcoded onMouseEnter and onMouseLeave events to focus and blur the noVNC rfb. This change allows customization of what happens with those events.
In the case of our project, the blurring on mouse leave is unnecessary and causes missed key-up events if a key is held when the mouse leaves the VncScreen component. Developers can customize behaviour by setting onChildMouseEnter and onChildMouseLeave as props on the VncScreen element.
This also modifies the default behavior of onMouseLeave to check if the target (cursor destination) is the noVNC mouse capture element. If the target is the noVNC mouse capture element it doesn't blur the rfb. This addresses the keyboard input issues caused by #5. Thanks to @richardstephens for the initial workaround which I cherry-picked into this branch.