Skip to content

Conversation

@YouJiacheng
Copy link
Contributor

Use onTapDown instead of onTap like ink = False
Also:
passing a dummy callback to onTap when onHover is True to enble the widget instead of
passing a ws.pageEventFromWeb callback to onTap and onLongPress to reduce websocket traffic

Use onTapDown instead of onTap like ink = False
Also:
passing a dummy callback to onTap when onHover is True to enble the widget
instead of
passing a ws.pageEventFromWeb callback to onTap and onLongPress
to reduce websocket traffic
@FeodorFitsner
Copy link
Contributor

Could you please elaborate what you changes about?

@FeodorFitsner
Copy link
Contributor

Is it about this?

@YouJiacheng
Copy link
Contributor Author

YouJiacheng commented Oct 2, 2022

Yes. First, I use onTapDown to trigger onclick callback instead of onTap when ink = True, which is the same as ink = False case, so that onclick callback can receive position data when ink = True.
Second, I use a dummy callback for onTap to keep widget enabled when onHover is True. Before this PR, full functionality callbacks were used for onTap AND onLongPress just to keep widget enabled when onHover is True, which will send message through ws.
Yes. This PR is about what I commented in website repo.

@FeodorFitsner
Copy link
Contributor

Cool, thank you!

@FeodorFitsner
Copy link
Contributor

That makes sense.

@YouJiacheng
Copy link
Contributor Author

I haven't tested this PR with flet because I dont know how to build flet client, I only made something similar in flutter playground.

@FeodorFitsner FeodorFitsner added this to the Controls-S2 milestone Oct 5, 2022
@FeodorFitsner FeodorFitsner merged commit c29478e into flet-dev:main Oct 6, 2022
@FeodorFitsner
Copy link
Contributor

FeodorFitsner commented Oct 6, 2022

OK, I found an issue with having both handlers onTapDown and onLongPress. It's impossible to distinguish between onTapDown and onLongPress: it triggers either just onTapDown or, if you hold it longer onTapDown and then onLongPress.
With onTap it triggers either onTap or onLongPress.

@FeodorFitsner
Copy link
Contributor

I suggest explicitly implement on_tap_down event, with coordinates.

@FeodorFitsner
Copy link
Contributor

I'm going to do this in the next update. Going to be a breaking change though.

@YouJiacheng
Copy link
Contributor Author

YouJiacheng commented Oct 6, 2022

It is intended (in flutter) that onTapDown and onLongPress are "indistinguishable" -- actually onTapDown will always be triggered (it even be fired for loser in gesture arena, except very short tap).

I suggest refactor the API to directly expose flutter's GestureDetector API, with same name and same "interface".

It might be even better to implement a flet GestureDetector as a replacement of this functionality of Container(leave current API as deprecated, or just remove them -- breaking change). I don't think that we should integrate so many functions into Container -- “Single Responsibility Principle”.

P.S.: Not only SRP, but also developer friendly. It is not easy to search in the docs and find out that flet supports (general) mouse event through Container.

@FeodorFitsner
Copy link
Contributor

Agree, implementing GestureDetector sounds right: #450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants