Stay organized with collections
Save and categorize content based on your preferences.
blockly > browserEvents > conditionalBind
browserEvents.conditionalBind() function
Bind an event handler that can be ignored if it is not part of the active touch stream. Use this for events that either start or continue a multi-part gesture (e.g. mousedown or mousemove, which may be part of a drag or click).
Signature:
export declare function conditionalBind(node: EventTarget, name: string, thisObject: object | null, func: Function, opt_noCaptureIdentifier?: boolean): 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. |
opt_noCaptureIdentifier |
boolean |
(Optional) True if triggering on this event should not block execution of other event handlers on this touch or other simultaneous touches. False by default. |
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\u003e\u003ccode\u003econditionalBind\u003c/code\u003e facilitates binding event handlers, specifically for events within multi-part gestures, like mouse clicks or drags.\u003c/p\u003e\n"],["\u003cp\u003eIt allows ignoring events outside the active touch stream to prevent unintended handler executions.\u003c/p\u003e\n"],["\u003cp\u003eThe function accepts parameters for the target node, event name, function context, handler function, and an optional flag to control simultaneous event execution.\u003c/p\u003e\n"],["\u003cp\u003eIt returns an opaque data object that can be later used for unbinding the event.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [browserEvents](./blockly.browserevents_namespace.md) \\\u003e [conditionalBind](./blockly.browserevents_namespace.conditionalbind_1_function.md)\n\nbrowserEvents.conditionalBind() function\n----------------------------------------\n\nBind an event handler that can be ignored if it is not part of the active touch stream. Use this for events that either start or continue a multi-part gesture (e.g. mousedown or mousemove, which may be part of a drag or click).\n\n**Signature:** \n\n export declare function conditionalBind(node: EventTarget, name: string, thisObject: object | null, func: Function, opt_noCaptureIdentifier?: boolean): 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| opt_noCaptureIdentifier | boolean | *(Optional)* True if triggering on this event should not block execution of other event handlers on this touch or other simultaneous touches. False by default. |\n\n**Returns:**\n\n[Data](./blockly.browserevents_namespace.data_typealias.md)\n\nOpaque data that can be passed to unbindEvent_."]]