-
I have a working brush component which I created which uses the ontouchhandler to handle what it should do. But I would like to create a generic brush component which can be added under any canvas and inherit the touch handler and handle it inside the brush component ? I still want the parent component to also be able to handle the onTouch events aswell though. https://gyazo.com/cec56ef6c0aaf366be1b3d30797a9a13
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The "problem" with touch handling in Skia is that there are no React components inside a Skia Canvas - only a declaration of the drawing you want Skia to perform. This means that there is no way for React, Skia or any of us to automatically know the position and size of a "component" you write inside of the Canvas - what if you added a complex path that are drawn in Skia? There would be no way to quickly detect if a touch was on this Path or outside of it. Our suggestion is that you create a way to detect if your brush component is touched when the Canvas' onTouch handler is called. This is unfortunately not the solution you're after, and this has been brought up before in our issues list - just remember that there are no components inside the Skia Canvas - only drawing operations that ends up in a single Skia rendering - so no easy way to detect touches and map then to components inside the Canvas - we've tried! :) :) |
Beta Was this translation helpful? Give feedback.
-
Yes was able to use the onTouch handler to get it to work. Thank you |
Beta Was this translation helpful? Give feedback.
The "problem" with touch handling in Skia is that there are no React components inside a Skia Canvas - only a declaration of the drawing you want Skia to perform.
This means that there is no way for React, Skia or any of us to automatically know the position and size of a "component" you write inside of the Canvas - what if you added a complex path that are drawn in Skia? There would be no way to quickly detect if a touch was on this Path or outside of it.
Our suggestion is that you create a way to detect if your brush component is touched when the Canvas' onTouch handler is called.
This is unfortunately not the solution you're after, and this has been brought up before in our issues list…