Repository navigation
feat(keyboard): hold modifiers for keyboard and mouse input inside a block - #655
Merged
Merged
Conversation
…block Chrome doesn't carry a pressed modifier over to later input events, so a shift+drag needed raw CDP commands. Keyboard#hold presses the given modifiers, makes every keyboard and mouse event in the block carry them and releases them when the block returns or raises. State lives only for the block, so a missing keyup can't leak into later input. Keyboard#down and #up raise ArgumentError for a modifier and point to hold: down used to crash with NoMethodError and up sent an empty keyup event. Mouse#move accepts modifiers: like down and up, and Mouse#click sends its modifiers with the preceding mousemove too. Refs #581.
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.
Fixes #581
Chrome doesn't carry a pressed modifier over to later input events: each CDP event needs its own
modifiers, so a shift+drag required rawInput.dispatchMouseEventcalls.Keyboard#hold(*modifiers) { }presses the modifiers, makes every keyboard and mouse event in the block carry them and releases them when the block returns or raises. Nested blocks press a key once, and a release failure after the block raised doesn't hide the original error. State lives only for the block, so a missing keyup can't leak into later input.hold(:shift) { type("abc") }typesABC, holding Cmd/Ctrl and typingaselects all.Mouse#moveacceptsmodifiers:likedownandup. An explicit value overrides the held keys for that event.Mouse#click(modifiers:)now sends the modifiers with itsmousemovetoo.Keyboard#down/#upraiseArgumentErrorfor a modifier and point tohold.down(:shift)used to crash withNoMethodErrorandup(:shift)sent an empty keyup event.