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

branch: catchSingleClick #945

Open
jessegreenberg opened this issue Feb 18, 2019 · 4 comments
Open

branch: catchSingleClick #945

jessegreenberg opened this issue Feb 18, 2019 · 4 comments

Comments

@jessegreenberg
Copy link
Contributor

A branch to try a solution for #939. In that issue we are trying to solve the problem that assistive devices often do not send keydown and keyup events to the browser, but only click events to represent element activation.

As a potential solution to this, I am considering no longer dispatching click as a scenery event and instead only dispatching keydown and keyup for a11y input. The idea is that if we receive a click event, we check for keydown/keyup events that were triggered on the same target. If we receive keydown/keyup events we can do nothing. But if we did not receive them, we send our own fake events to mimic keydown and keyup.

This way, we can support all of the options that work generally for PhET buttons (#939 (comment)) and also support native HTML and typical ARIA roles for activatable elements buttons, links, check boxes, and so on.

@jessegreenberg jessegreenberg self-assigned this Feb 18, 2019
@jessegreenberg
Copy link
Contributor Author

In the branch, most of the implementation for this is in A11yEventCatcher (hopefully to be renamed to something better).

@jessegreenberg
Copy link
Contributor Author

jessegreenberg commented Feb 21, 2019

@zepumph and I had discussed trying alternatives to creating native DOM events and dispatching/firing through the DOM API. This was OK for test code, but doesn't seem good for sims. I tried to use Input.serializeDOMEvent (previously added for PhET-iO) to create an event like object that we can pass through Input.js. But we will need to add additional information to that function to get all keydown properties. I am not saying that isn't possible, but I don't want to add things to that function yet.

For exploration now, I will just make my own object that has the data of a a keydown event.

EDIT: I did that and hit an assertion:

Assertion failed: value should be instanceof Event, value=[object Object]

Because keydownEmitter specifies window.Event in argumentTypes.

EDIT2: Going back to trying Input.serializeDOMEvent/deserializeDOMEvent, but wonder if I will run into issues because I want to change properties like type on the fake event and those are read only.

EDIT3: Yes, I received

ncaught TypeError: Cannot assign to read only property 'type' of object '#'

EDIT4: The keyboardEvent constructor is supported in many places, but not IE https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent
So I think the best thing is to create our own kind of "FakeKeyboardEvent" type that the Input.js emitters can receive.

@jessegreenberg
Copy link
Contributor Author

jessegreenberg commented Feb 21, 2019

This is working well enough that I think it is a viable possibility. I will report back in #939

@jessegreenberg
Copy link
Contributor Author

See #939 (comment) for a summary of these changes. Pending further discussion in that issue.

@jessegreenberg jessegreenberg removed their assignment Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant