mootools / mootools-core

MooTools Core Repository
https://mootools.net
2.65k stars 505 forks source link

Events confusion #2771

Closed NaridaL closed 7 years ago

NaridaL commented 7 years ago

Maybe I'm missing something, but it seems the event handling documentation could be clearer. The documentation for http://mootools.net/core/docs/1.6.0/Element/Element.Event doesn't specify the expected signature of the event handler function (fn in myElement.addEvent(type, fn);)

The assumption that it's the same as the standard addEventListener is wrong, because it gets passed a Mootools Event (whose documentation is broken: http://mootools.net/core/docs/1.6.0/Element/Element.Event links to http://mootools.net/core/docs/1.6.0/Types/Event#Event:stop which 404s).

The Mootools Event isn't compatible with the standard one, for example shiftKey is renamed to shift, although it's not really clear why. cf. https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey and https://w3c.github.io/uievents/#dom-keyboardevent-shiftkey

DimitarChristoff commented 7 years ago

they are normalised events. see http://mootools.net/core/docs/1.6.0/Types/DOMEvent

SergioCrisostomo commented 7 years ago

@NaridaL as @DimitarChristoff pointed out MooTools creates its own Event object, the purpose is to provide a object with normalized values so you get the same values out of it in all browsers.

You can still access the original event, you can access it in the .event property. The MooTools own event object stores the event the browser issues in that property. There you can find .shiftKey and other event properties not normalized, which means you can have different values in different browsers.

NaridaL commented 7 years ago

@SergioCrisostomo Thanks for the info, I had missed something, as I thought. However it seems the underlying issue of the broken links and the doc not being very informative is still open...?

SergioCrisostomo commented 7 years ago

@NaridaL good point! Sent a pull request to fix that broken link. Thanks!