Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > browserEvents > bind
utils.browserEvents.bind() function
Bind an event handler that should be called regardless of whether it is part of the active touch stream. Use this for events that are not part of a multi-part gesture (e.g. mouseover for tooltips).
Signature:
export declare function bind(node: EventTarget, name: string, thisObject: object | null, func: Function): Data;
Parameters
Parameter |
Type |
Description |
node |
EventTarget |
Node upon which to listen. |
name |
string |
Event name to listen to (e.g. 'mousedown'). |
thisObject |
object | null |
The value of 'this' in the function. |
func |
Function |
Function to call when event is triggered. |
Returns:
Data
Opaque data that can be passed to unbindEvent_.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eutils.browserEvents.bind()\u003c/code\u003e function attaches an event handler to a node, ensuring it's called even outside active touch interactions.\u003c/p\u003e\n"],["\u003cp\u003eIt's ideal for events like mouseovers that are not part of multi-step gestures.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes the event target, event name, 'this' context for the handler, and the handler function itself as arguments.\u003c/p\u003e\n"],["\u003cp\u003eIt returns an opaque data object used for detaching the event handler later.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [utils](./blockly.utils_namespace.md) \\\u003e [browserEvents](./blockly.utils_namespace.browserevents_namespace.md) \\\u003e [bind](./blockly.utils_namespace.browserevents_namespace.bind_1_function.md)\n\nutils.browserEvents.bind() function\n-----------------------------------\n\nBind an event handler that should be called regardless of whether it is part of the active touch stream. Use this for events that are not part of a multi-part gesture (e.g. mouseover for tooltips).\n\n**Signature:** \n\n export declare function bind(node: EventTarget, name: string, thisObject: object | null, func: Function): Data;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|------------|----------------|---------------------------------------------|\n| node | EventTarget | Node upon which to listen. |\n| name | string | Event name to listen to (e.g. 'mousedown'). |\n| thisObject | object \\| null | The value of 'this' in the function. |\n| func | Function | Function to call when event is triggered. |\n\n**Returns:**\n\n[Data](./blockly.browserevents_namespace.data_typealias.md)\n\nOpaque data that can be passed to unbindEvent_."]]