Search.../

Introduction

Events can be caused by user interactions, such as clicking the mouse or pressing a key, or generated programmatically, such as hiding or showing an element using the hide() and show() functions.

Because the functionality provided by Event can be inherited and used when actions occur to elements, it is considered a "mixin."

About Mixins

Mixins provide functionality that other elements and event handlers can inherit and use.

Mixins are not elements. You cannot add mixins to a page in the Editor like other $w elements, and mixins are not meant to be used directly in your code.

For example, you would not write code like this, because it is out of context:

$w("#Event").onEvent( (event) => {
let eventType = event.type;
} );
javascript | Copy Code

Instead, you can code the following if myElement has an event handler that "mixes in" Event.

$w("#myElement").onEvent( (event) => {
let eventType = event.type;
} );
javascript | Copy Code

Was this helpful?