tldraw / tldraw-v1

A tiny little drawing app. This is the original 2021-2022 version, released under MIT.
https://old.tldraw.com
MIT License
61 stars 36 forks source link

I'm using @tldraw/tldraw. I would like to know which event will be triggered when a user clicks a shape. #55

Closed xujinglong2021 closed 8 months ago

xujinglong2021 commented 1 year ago

I'm using @tldraw/tldraw. I would like to know which event will be triggered when a user clicks a shape. I would appreciate it if you could post a piece of code.

judicaelandria commented 1 year ago

Hi! we don't exactly have an exact event for that but you can achieve the same thing using onPatch(app, patch, reason)

<Tldraw onPatch={(app, patch) => {
   // if the status is pointingBounds that mean the user is clicking a shape
   if(patch.appState.status === "pointingBounds") {
      // do what you want here
   }
}} />
xujinglong2021 commented 1 year ago

Hi! we don't exactly have an exact event for that but you can achieve the same thing using onPatch(app, patch, reason)

<Tldraw onPatch={(app, patch) => {
   // if the status is pointingBounds that mean the user is clicking a shape
   if(patch.appState.status === "pointingBounds") {
      // do what you want here
   }
}} />

Wow, so nice of you!