flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.18k stars 430 forks source link

WebView to handle clicks and link clicks like with markdown.on_link_tap #2164

Open Petrox opened 10 months ago

Petrox commented 10 months ago

In a webview the user interacts with the content. Somewhat similar to markdown control.

This interaction might lead to changing the url (eg. clicking a link, or activating something that changes the page url). Somewhat similar to markdown.

It would be nice and consistent when the developer could catch these events with an on_link_tap handler and decide what to do with it. Somewhat similar to markdown.

(Eg: one could load a custom generated svg in a webview that includes links, and then the user could click on them which would change the behaviour of the app. Note markdown does not support svg currently and image control does not support svg links, soo webview could be the third way)

gbrandt commented 10 months ago

This would make links not work in safari due to security handling unless it is fully optional and links still work as expected without the on_link_tap handler

Petrox commented 10 months ago

That would be a platform specific limitation, which is understandable of course (at least there is not much to do with it)

FeodorFitsner commented 10 months ago

There is, actually, a mechanism for that: https://github.com/flet-dev/flet/blob/main/package/lib/src/controls/webview.dart#L73-L78

It's just currently you can control prohibited links via WebView.prevent_link property.

Will look into adding proper callback.

Petrox commented 10 months ago

For some usecases it could be useful even if just custom links could be caught (eg click:// or similar). So the properly prepared content could interact with the outside world of the webview

On Thu, Nov 30, 2023 at 12:06 AM Feodor Fitsner @.***> wrote:

There is, actually, a mechanism for that: https://github.com/flet-dev/flet/blob/main/package/lib/src/controls/webview.dart#L73-L78

It's just currently you can control prohibited links via WebView.prevent_link property.

Will look into adding proper callback.

— Reply to this email directly, view it on GitHub https://github.com/flet-dev/flet/issues/2164#issuecomment-1832841615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXFKXJTOOMPHSRKYY4ELADYG65XLAVCNFSM6AAAAABAAFFP4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZSHA2DCNRRGU . You are receiving this because you authored the thread.Message ID: @.***>