-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added onTap feature for chartJS #1690
Conversation
// Add click event listener to the chart | ||
document.getElementById("${widget.controller.chartId}").onclick = function(event) { | ||
// Notify Flutter about the click event (no need to send data) | ||
if (window.dispatchEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are sending the event anyway, why not send data as well? It is important in general to send the data along with the event even if not needed for this use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I have updated the available data in it.
WebViewWidget(controller: controller), | ||
WebViewWidget( | ||
controller: controller, | ||
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configure the gestureRecognizers only if a listener has been specified. You don't want to capture clicks if there is no listener
@@ -100,7 +100,7 @@ class JsWidgetState extends State<JsWidget> { | |||
void initState() { | |||
if (widget.listener != null) { | |||
addListener(widget.id, widget.listener!); | |||
init(globalListener); | |||
_setupFlutterWebCommunication(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the init method sets up the interop. How will it work without calling that method?
@@ -114,6 +114,14 @@ class JsWidgetState extends State<JsWidget> { | |||
}); | |||
super.initState(); | |||
} | |||
// Setup Flutter web communication for JS interactions | |||
void _setupFlutterWebCommunication() { | |||
html.window.addEventListener('callFlutter', (event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who dispatches the callFlutter event? why not use the interop?
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{ | ||
Factory<OneSequenceGestureRecognizer>( | ||
() => TapGestureRecognizer() | ||
..onTapDown = (TapDownDetails details) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the point of this if you are not doing anything inside it? also as requested earlier, if you really need to add gesturerecognizer, add it only if there is an onTap that the developer has specified. In this case I think you don't even need this piece of code at all right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First i thought that, that as it is a webView, mobile gesture detector wont work unless we detect it and then pass it to JsBridge to communicate with web, but yeah read more about it and tested it without this, understood how it is working. Thanks for pointing out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test on web, ios and android. Also add schema, kitchen sink example and documentation as well. Thank you
Revert "Merge pull request #1690 from EnsembleUI/chartJS0x45"
Ticket: #1685
Tested with the Android build and well with CanvasKit and HTML.
Example EDL: