markEventAsHandled
See source codeIn tldraw, events are sometimes handled by multiple components. For example, the shapes might
have events, but the canvas handles events too. The way that the canvas handles events can
interfere with the with the shapes event handlers - for example, it calls .preventDefault()
on
pointerDown
, which also prevents click
events from firing on the shapes.
You can use .stopPropagation()
to prevent the event from propagating to the rest of the DOM,
but that can impact non-tldraw event handlers set up elsewhere. By using markEventAsHandled
,
you'll stop other parts of tldraw from handling the event without impacting other, non-tldraw
event handlers. See also wasEventAlreadyHandled.
function markEventAsHandled(
e:
| {
nativeEvent: Event
}
| Event
): void
Parameters
Name | Description |
---|---|
|
|
Returns
void
Prev
loopToHtmlElementNext
maybeSnapToGrid