How do I set editor tool to draw a rectangle using external-ui? #3714
-
I was following this tutorial https://tldraw.dev/examples/ui/external-ui to make an external-ui, but I couldn't seem to be able to find what the name of the tool for shapes like rectangle or ellipses were. I tried geo.idle, geo.rectangle, rectangle etc. So how can I set the editor tool to something like a rectangle? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Geo shapes are a little weird in that they're all the same shape, but the visual is determined by a style. So you need to set the tool, but also use e.g. You can see how we do this in our own UI here: tldraw/packages/tldraw/src/lib/ui/hooks/useTools.tsx Lines 103 to 109 in ebc892a |
Beta Was this translation helpful? Give feedback.
Geo shapes are a little weird in that they're all the same shape, but the visual is determined by a style. So you need to set the tool, but also use e.g.
editor.setStyleForNextShape(GeoShapeGeoStyle, 'cloud')
.You can see how we do this in our own UI here:
tldraw/packages/tldraw/src/lib/ui/hooks/useTools.tsx
Lines 103 to 109 in ebc892a